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


C++ NodeRef::setStored方法代码示例

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


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

示例1: update

bool NodeStore::update(NodeRef &node, NodeRefList *nl)
{
        Mutex::AutoLocker l(mutex);
	bool found = false;
	
	if (!node)
		return false;

	// There may be undefined nodes in the node store that should
	// be removed/merged with a 'defined' node that we create from a 
	// node description. We loop through all nodes in the store and
	// compare their interface lists with the one in the 'defined' node.
	// If any interfaces match, we remove the matching nodes in the store 
	// and eventually replace them with the new one.
	for (NodeStore::iterator it = begin(); it != end();) {
		NodeRecord *nr = *it;
		bool found_now = false;
		
		nr->node.lock();

		const InterfaceRefList *ifaces = nr->node->getInterfaces();

		for (InterfaceRefList::const_iterator it2 = ifaces->begin(); it2 != ifaces->end(); it2++) {
			InterfaceRef iface = *it2;

			if (node->hasInterface(iface)) {
				// Transfer all the "up" interface states to the updated node
				if (iface->isUp())
					node->setInterfaceUp(iface);

				found_now = true;
			}
		}
		nr->node.unlock();

		if (found_now) {
			if (nl)
				nl->push_back(nr->node);
			
			nr->node->setStored(false);

			node->setExchangedNodeDescription(nr->node->hasExchangedNodeDescription());
				
			it = erase(it);
			delete nr;
			found = true;
		} else {
			it++;
		}
	}
	if (found) {
		node->setStored(true);
		push_back(new NodeRecord(node));
	}

	return found;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:57,代码来源:NodeStore.cpp

示例2: add

bool NodeStore::add(NodeRef &node)
{
        Mutex::AutoLocker l(mutex);

	if (!node)
		return false;;

	if (_stored(node)) {
		HAGGLE_DBG("Node %s is already in node store\n", node->getIdStr());
		return false;
	}

	HAGGLE_DBG("Adding new node to node store %s\n", node->getIdStr());
	node->setStored();
	push_back(new NodeRecord(node));

	return true;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:18,代码来源:NodeStore.cpp

示例3: remove

// Remove neighbor with a specified interface
NodeRef NodeStore::remove(const InterfaceRef &iface)
{
        Mutex::AutoLocker l(mutex);

	if (!iface)
		return NULL;

	for (NodeStore::iterator it = begin(); it != end(); it++) {
		NodeRecord *nr = *it;

		if (nr->node->hasInterface(iface)) {
			NodeRef node = nr->node;
			erase(it);
			node->setStored(false);
			delete nr;
			return node;
		}
	}

	return NULL;
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:22,代码来源:NodeStore.cpp


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