本文整理汇总了C++中CDatabase::initTimestamps方法的典型用法代码示例。如果您正苦于以下问题:C++ CDatabase::initTimestamps方法的具体用法?C++ CDatabase::initTimestamps怎么用?C++ CDatabase::initTimestamps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatabase
的用法示例。
在下文中一共展示了CDatabase::initTimestamps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildReference
/*
* Adapt database to new description
* \param description is the latest xml description of the database
* \returns true is adaptation succeded
*/
CDatabase* CDatabase::adapt(const string& description)
{
PDS_DEBUG("adapt()");
if (!initialised())
{
PDS_WARNING("adapt(): failed, database not initialised");
return NULL;
}
// get 'From' HashKey
CHashKey hash1 = _Description.getHashKey();
// get 'Into' HashKey
CHashKey hash2 = getSHA1((const uint8*)(description.c_str()), (uint32)description.size());
// same hash, ok go on
if (hash1 == hash2)
return this;
// build a clean reference if needed
if (!isReferenceUpToDate())
{
if (!buildReference())
{
PDS_WARNING("adapt(): failed to buildReference()");
return false;
}
}
// backup old reference
if (!_Reference.save(_Reference.getPath()+"ref"))
{
PDS_WARNING("adapt(): failed to backup reference index");
}
// create a new destination database
CDatabase* into = new CDatabase(_State.Id);
if (!into->createFromScratch(description))
{
PDS_WARNING("adapt(): failed to create new reference");
delete into;
return NULL;
}
CDatabaseAdapter adapter;
if (!adapter.build(this, into))
{
PDS_WARNING("adapt(): failed to build() adapter");
delete into;
return NULL;
}
if (!adapter.buildContent())
{
PDS_WARNING("adapt(): adapter failed to buildContent()");
delete into;
return NULL;
}
// rebuild volatile data
// that is all non persistant data that can be found from persistant data
if (!into->rebuildVolatileData())
{
PDS_WARNING("adapt(): failed to rebuildVolatileData()");
delete into;
return NULL;
}
// init timestamps as database is ready to run
into->initTimestamps();
return into;
}