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


C++ HDB::setLastRootOffset方法代码示例

本文整理汇总了C++中HDB::setLastRootOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ HDB::setLastRootOffset方法的具体用法?C++ HDB::setLastRootOffset怎么用?C++ HDB::setLastRootOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HDB的用法示例。


在下文中一共展示了HDB::setLastRootOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool
HDBNode::remove(HDBHandle& hdl)
{
	// If node hasn't been written yet, don't do anything.
	if (m_pdata->m_offset <= 0)
	{
		return false;
	}
	File file = hdl.getFile();
	HDB* pdb = hdl.getHDB();
	HDBBlock fblk;
	// Remove all children
	Int32 coffset = m_pdata->m_blk.lastChild;
	Int32 toffset;
	while (coffset > 0)
	{
		HDB::readBlock(fblk, file, coffset);
		toffset = coffset;			// Save offset for deletion class
		coffset = fblk.prevSib;		// Save offset for next read
		// Remove node and all of its children. This call will modify fblk.
		removeBlock(hdl, fblk, toffset);
	}
	// Set pointer on next sibling if it exists
	if (m_pdata->m_blk.nextSib > 0)
	{
		HDB::readBlock(fblk, file, m_pdata->m_blk.nextSib);
		fblk.prevSib = m_pdata->m_blk.prevSib;
		HDB::writeBlock(fblk, file, m_pdata->m_blk.nextSib);
	}
	// Set pointer on prev sibling if it exists
	if (m_pdata->m_blk.prevSib > 0)
	{
		HDB::readBlock(fblk, file, m_pdata->m_blk.prevSib);
		fblk.nextSib = m_pdata->m_blk.nextSib;
		HDB::writeBlock(fblk, file, m_pdata->m_blk.prevSib);
	}
	// If it has a parent, insure parent doesn't contain it's offset
	if (m_pdata->m_blk.parent > 0)
	{
		// Read parent block
		HDB::readBlock(fblk, file, m_pdata->m_blk.parent);
		bool changed = false;
		// If this was the first child in the list, then update the
		// first child pointer in the parent block
		if (fblk.firstChild == m_pdata->m_offset)
		{
			changed = true;
			fblk.firstChild = m_pdata->m_blk.nextSib;
		}
		// If this was the last child in the list, then update the
		// last child pointer in the parent block
		if (fblk.lastChild == m_pdata->m_offset)
		{
			changed = true;
			fblk.lastChild = m_pdata->m_blk.prevSib;
		}
		// If any offsets changed in the parent block, then update the parent
		if (changed)
		{
			HDB::writeBlock(fblk, file, m_pdata->m_blk.parent);
		}
	}
	else
	{
		// Must be a root node
		if (pdb->getFirstRootOffSet() == m_pdata->m_offset)
		{
			pdb->setFirstRootOffSet(file, m_pdata->m_blk.nextSib);
		}
		if (pdb->getLastRootOffset() == m_pdata->m_offset)
		{
			pdb->setLastRootOffset(file, m_pdata->m_blk.prevSib);
		}
	}
	// Add block to free list
	pdb->addBlockToFreeList(file, m_pdata->m_blk, m_pdata->m_offset);
	// Remove the index entry for this node
	hdl.removeIndexEntry(m_pdata->m_key.c_str());
	m_pdata->m_offset = -1;
	m_pdata->m_blk.isFree = true;
	m_pdata->m_blk.parent = -1;
	m_pdata->m_blk.firstChild = -1;
	m_pdata->m_blk.lastChild = -1;
	m_pdata->m_blk.prevSib = -1;
	m_pdata->m_blk.nextSib = -1;
	m_pdata->m_blk.size = 0;
	hdl.registerWrite();
	return true;
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:89,代码来源:OW_HDBNode.cpp


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