本文整理汇总了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;
}
示例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;
}
示例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;
}