本文整理汇总了C++中NodeRefPtr::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::begin方法的具体用法?C++ NodeRefPtr::begin怎么用?C++ NodeRefPtr::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeRefPtr
的用法示例。
在下文中一共展示了NodeRefPtr::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare
void
Tree::search_recursive(const ResourceName &resName,
const NodeRefPtr node,
std::vector<PDRefCntPtr> &results,
bool usePatterns) const {
am_resource_match_t compRes;
compRes = compare(node->getPolicyDecision()->getName(),
resName,
usePatterns);
std::list<NodeRefPtr>::const_iterator iter;
switch(compRes) {
case AM_EXACT_MATCH:
results.push_back(node->getPolicyDecision());
break;
case AM_EXACT_PATTERN_MATCH:
results.push_back(node->getPolicyDecision());
// fall through to the following
case AM_SUB_RESOURCE_MATCH:
case AM_NO_MATCH:
for(iter = node->begin(); iter != node->end(); iter++) {
search_recursive(resName, *iter, results, usePatterns);
}
break;
default:
break;
}
return;
}
示例2: SearchResult
SearchResult
Tree::find(NodeRefPtr startNode, const ResourceName &policyRes,
bool usePatterns = true) {
am_resource_match_t compRes;
std::list<NodeRefPtr>::const_iterator iter;
const ResourceName& resName = startNode->getPolicyDecision()->getName();
compRes = compare(resName, policyRes, usePatterns);
if(compRes != AM_SUB_RESOURCE_MATCH && compRes != AM_EXACT_PATTERN_MATCH) {
if(compRes == AM_EXACT_MATCH)
return SearchResult(AM_EXACT_MATCH, startNode);
return SearchResult(compRes, Node::NULL_NODE);
}
for(iter = startNode->begin(); iter != startNode->end(); ++iter) {
NodeRefPtr node = *iter;
const PDRefCntPtr &element = node->getPolicyDecision();
switch((compare(element->getName(), policyRes, usePatterns))) {
case AM_EXACT_MATCH:
return SearchResult(AM_EXACT_MATCH, node);
break;
case AM_NO_MATCH:
continue;
break;
case AM_SUPER_RESOURCE_MATCH:
return SearchResult(AM_SUB_RESOURCE_MATCH, startNode);
case AM_SUB_RESOURCE_MATCH:
case AM_EXACT_PATTERN_MATCH:
{
SearchResult result = find(node, policyRes, usePatterns);
switch(result.first) {
// In case of the node below returns SUB_RESOURCE_MATCH,
// EXACT_PATTERN_MATCH or EXACT_MATCH,
// we just need to pass on the result upwards.
case AM_SUB_RESOURCE_MATCH:
case AM_EXACT_PATTERN_MATCH:
case AM_EXACT_MATCH:
// Bingo! got a match.
return result;
case AM_SUPER_RESOURCE_MATCH:
case AM_NO_MATCH:
return SearchResult(AM_SUB_RESOURCE_MATCH, startNode);
}
}
break;
}
}
// This is the level we have to add the node.
if(iter == startNode->end()) {
if(compRes == AM_SUB_RESOURCE_MATCH || compRes == AM_EXACT_PATTERN_MATCH)
return SearchResult(compRes, startNode);
else
return SearchResult(compRes, Node::NULL_NODE);
}
return SearchResult(AM_NO_MATCH, Node::NULL_NODE);
}
示例3: newNode
bool
Tree::insertBelow(NodeRefPtr parent, PDRefCntPtr &elem) {
std::list<NodeRefPtr>::iterator iter;
NodeRefPtr newNode(new Node(parent, elem));
// add the subordinate nodes of newNode under
// new node. In the next loop, we iterate nodes
// under new node and remove them from parent.
// Reason: if we remove nodes under parent in this
// loop, iterator becomes invalid.
ScopeLock myLock(treeLock);
for(iter = parent->begin(); iter != parent->end(); iter++) {
NodeRefPtr node = *iter;
PDRefCntPtr data = node->getPolicyDecision();
switch(compare(data->getName(), elem->getName(), false)) {
case AM_EXACT_MATCH:
case AM_SUB_RESOURCE_MATCH:
return false;
case AM_NO_MATCH:
break;
case AM_SUPER_RESOURCE_MATCH:
newNode->addNode(node);
break;
}
}
for(iter = newNode->begin(); iter != newNode->end(); iter++) {
NodeRefPtr node = *iter;
parent->remove(node);
}
parent->addNode(newNode);
return true;
}