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


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

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


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

示例1: _endNeighbor

void ForwarderRank::_endNeighbor(const NodeRef &neighbor)
{
	// We don't handle routing to anything but other haggle nodes:
	if (neighbor->getType() != Node::TYPE_PEER)
		return;
	
	// Update our private metric regarding this node:
	bubble_node_id_t neighbor_id = id_from_string(neighbor->getIdStr());
	
	HAGGLE_DBG("HAGGLE_DBG: _endNeighbor node left: node %ld %s \n", neighbor_id, neighbor->getIdStr());

	rib_timestamp = Timeval::now();
}
开发者ID:eikoyoneki,项目名称:haggle-cambridge,代码行数:13,代码来源:ForwarderRank.cpp

示例2: _generateDelegatesFor

void ForwarderRank::_generateDelegatesFor(const DataObjectRef &dObj, const NodeRef &target, const NodeRefList *other_targets)
{
						
	List<Pair<NodeRef, bubble_metric_t> > sorted_delegate_list;
	
	// Figure out which node to look for:
	bubble_node_id_t target_id = id_from_string(target->getIdStr());
	
	LABEL_T targetLabel = rib[target_id].first;
	//RANK_T targetRank = rib[target_id].second;
	
	HAGGLE_DBG("HAGGLE_DBG:_generateDelegatesFor node %d string %s label %s\n", target_id, target->getIdStr(), targetLabel.c_str());


	for (bubble_rib_t::iterator it = rib.begin();it != rib.end(); it++)
	{
		if (it->first != this_node_id && it->first != target_id) {

			NodeRef delegate = kernel->getNodeStore()->retrieve(id_number_to_nodeid[it->first], true);

			if (delegate && !isTarget(delegate, other_targets)) {
				
				LABEL_T &neighborLabel = it->second.first;
				RANK_T &neighborRank = it->second.second;
				
				HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor neighborLabel=%s, targetLabel=%s\n", neighborLabel.c_str(), targetLabel.c_str());
				
				if (neighborLabel.compare(targetLabel)==0)
				{
					//NodeRef delegate = Node::create_with_id(Node::TYPE_PEER, id_number_to_nodeid[it->first].c_str(), "Label delegate node");
					sortedNodeListInsert(sorted_delegate_list, delegate, it->second);
					HAGGLE_DBG("HAGGLE_DBG: _generateDelegatesFor Label same: Node '%s' is a good delegate for target '%s' [label=%s, rank=%ld]\n", 
					delegate->getName().c_str(), target->getName().c_str(), neighborLabel.c_str(), neighborRank);
					
				}
			}
		}
	}
	
	// Add up to max_generated_delegates delegates to the result in order of decreasing metric
	if (!sorted_delegate_list.empty()) {
		
		NodeRefList delegates;
		unsigned long num_delegates = max_generated_delegates;
		
		while (num_delegates && sorted_delegate_list.size()) {
			NodeRef delegate = sorted_delegate_list.front().first;
			sorted_delegate_list.pop_front();
			delegates.push_back(delegate);
			num_delegates--;
		}
		kernel->addEvent(new Event(EVENT_TYPE_DELEGATE_NODES, dObj, target, delegates));
		HAGGLE_DBG("HAGGLE_DBG: Forward Generated %lu delegates for target %s\n", delegates.size(), target->getName().c_str());
	} else {
                HAGGLE_DBG("No delegates found for target %s\n", target->getName().c_str());
    }

}
开发者ID:eikoyoneki,项目名称:haggle-cambridge,代码行数:58,代码来源:ForwarderRank.cpp

示例3: 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

示例4: retrieve

NodeRef NodeStore::retrieve(const string &id, bool mustBeNeighbor)
{
        Mutex::AutoLocker l(mutex);

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

		if (mustBeNeighbor && !node->isNeighbor())
			continue;

		if (memcmp(id.c_str(), node->getIdStr(), MAX_NODE_ID_STR_LEN) == 0) 
			return node;
	}

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


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