当前位置: 首页>>代码示例>>C++>>正文


C++ CDatabase::initTimestamps方法代码示例

本文整理汇总了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;
}
开发者ID:,项目名称:,代码行数:80,代码来源:


注:本文中的CDatabase::initTimestamps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。