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


C++ NetworkNode类代码示例

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


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

示例1: loadServers

void Server::loadServers(const std::string & path) {
    // The add server lambda function:
    auto addServer = [] (const std::string & host, const std::string & service) {
        try {
            NetworkNode node;
            node.Initialize(host, service);
            Network::AddNode(node);
        } catch (std::exception & e) {
            std::cerr << "[Server::loadServers::addServer] catch => std::exception" << std::endl;
            std::cerr << "+ WHAT: " << e.what() << std::endl;
        }
    };
    // Clear the current nodes:
    Network::ClearNodes();
    // Add the local node to the table:
    auto & portNumber = Options::Get(Options::PortNumberKey);
    addServer(LOCAL_HOST, portNumber);
    // Load the lines inside the servers configuration file:
    std::string line, address, port;
    std::ifstream file(path);
    while (std::getline(file, line)) {
        // This is a Comma-separated values file:
        std::stringstream sline(line);
        bool ok = std::getline(sline, address, ',') &&
                  std::getline(sline, port, ',') &&
                  IsPortNumber(port);
        if (ok) {
            addServer(address, port);
        } else {
            std::cerr << "[Server::loadServers] Wrong line!" << std::endl;
            std::cerr << "+ FILE: " << path << std::endl;
            std::cerr << "+ LINE: " << line << std::endl;
        }
    }
}
开发者ID:edsystems,项目名称:Medusa,代码行数:35,代码来源:Server.cpp

示例2: GetSourceNode

double
MacroCellUrbanAreaChannelRealization::GetPathLoss (void)
{
  /*
   * According to  ---  insert standard 3gpp ---
   * the Path Loss Model For Urban Environment is
   * L = I + 37.6log10(R)
   * R, in kilometers, is the distance between two nodes
   * I = 128.1 at 2GHz
   */
  double distance;
  double externalWallAttenuation = 20; //[dB]

  NetworkNode* src = GetSourceNode ();
  NetworkNode* dst = GetDestinationNode ();

  distance = src->GetMobilityModel ()->GetAbsolutePosition ()->GetDistance (
		  dst->GetMobilityModel ()->GetAbsolutePosition ());

  /*
  if (GetSourceNode ()->GetNodeType () == NetworkNode::TYPE_UE
		  && GetDestinationNode ()->GetNodeType () == NetworkNode::TYPE_ENODEB)
    {
	  UserEquipment* ue = (UserEquipment*) GetSourceNode ();
	  ENodeB* enb = (ENodeB*) GetDestinationNode ();

	  distance =  ue->GetMobilityModel ()->GetAbsolutePosition ()->GetDistance (enb->GetMobilityModel ()->GetAbsolutePosition ());
    }

  else if (GetDestinationNode ()->GetNodeType () == NetworkNode::TYPE_UE
		  && GetSourceNode ()->GetNodeType () == NetworkNode::TYPE_ENODEB)
    {
	  UserEquipment* ue = (UserEquipment*) GetDestinationNode ();
	  ENodeB* enb = (ENodeB*) GetSourceNode ();

	  distance =  ue->GetMobilityModel ()->GetAbsolutePosition ()->GetDistance (enb->GetMobilityModel ()->GetAbsolutePosition ());
    }
  */

  m_pathLoss = 128.1 + (37.6 * log10 (distance * 0.001));

  UserEquipment* ue;
  if (GetSourceNode ()->GetNodeType () == NetworkNode::TYPE_UE)
    {
	  ue = (UserEquipment*) GetSourceNode ();
    }
  else
   {
	  ue = (UserEquipment*) GetDestinationNode ();
   }

  if ( ue->IsIndoor() )
  {
	  m_pathLoss = m_pathLoss + externalWallAttenuation;
  }


  return m_pathLoss;
}
开发者ID:AbubakarAuwal,项目名称:lte-sim,代码行数:59,代码来源:macrocell-urban-area-channel-realization.cpp

示例3: switch

/**
 * Given a NodeInfoMsg inserts the node into NetworkNode database.
 * @param session can be null
 * Returns true if new node inserted, false if already present
 * Delete the message
 */
bool NodeNetworkSystem::_addNetworkNode(Session* session, NodeInfoMsg* msg) {
	if (_DEBUG)
		cout << "NodeNetworkSystem::_addNetworkNode" << endl;

	bool retval = false;
	NetworkNode* connectedNode = NetworkNode::getNodeById(msg->getId());
	if (connectedNode == NULL) {
		/* The connected node is unknown. Add it */
		retval = true;
		if (_DEBUG)
			cout
					<< "NodeNetworkSystem::_addNetworkNode: creating a new NetworkNode"
					<< endl;
		switch (msg->getNodeType()) {
		case NODETYPE_CAMERA:
			connectedNode = NetworkNode::addCamera(msg->getId(),
					msg->getAmAddress(), msg->getIpAddress(),
					msg->getServerPort());
			break;
		case NODETYPE_COOPERATOR:
			connectedNode = NetworkNode::addCooperator(msg->getId());
			break;
		default:
			if (_DEBUG)
				cerr
						<< "NodeNetworkSystem::_addNetworkNode: Error! Notification of a type "
						<< msg->getNodeType() << " node!" << endl;
			return false;
		}
		if (_DEBUG) {
			cout
					<< "NodeNetworkSystem::_addNetworkNode: Network Topology updated "
					<< endl;
			NetworkNode::printNetwork();
		}
	}
	if (session) {
		connectedNode->setSession(session);
	}
	if (connectedNode->getType() == NODETYPE_COOPERATOR) {
		switch (NetworkNode::getMyself()->getType()) {
		case NODETYPE_CAMERA: {
			_offloadingManager->addCooperator(connectedNode);
			CoopInfoMsg* infoMsg = new CoopInfoMsg(NetworkNode::getMyself(),
					NetworkNode::getSink(), LINKTYPE_TCP,
					_offloadingManager->getCooperatorsIds());
			sendMessage(infoMsg);
			break;
		}
		default:
			break;
		}
	}

	delete msg;

	return retval;
}
开发者ID:greeneyesproject,项目名称:testbed-demo,代码行数:64,代码来源:NodeNetworkSystem.cpp

示例4: E_DEBUG

void Network::buildExecutionNetwork() {
  E_DEBUG(ENetwork, "building execution network");
  clearExecutionNetwork();

  // 1- First build the visible network
  E_DEBUG(ENetwork, "  1- build visible network");
  E_DEBUG_INDENT;

  FractalNode* executionNetworkRoot = visibleNetwork<FractalNode>(_generator);

  FNodeVector visibleNodes = depthFirstSearch(executionNetworkRoot);

  // 2- Expand all the nodes of this first graph
  E_DEBUG_OUTDENT;
  E_DEBUG(ENetwork, "  2- expand nodes");
  E_DEBUG_INDENT;

  expandNodes(visibleNodes);

  // 3- connect the expanded versions of the nodes together
  E_DEBUG_OUTDENT;
  E_DEBUG(ENetwork, "  3- connect expanded network");
  E_DEBUG_INDENT;
  connectExpandedNodes(visibleNodes);

  // 4- construct our "clean" execution network and clean up the FractalNodes
  E_DEBUG_OUTDENT;
  E_DEBUG(ENetwork, "  4- construct final network");
  E_DEBUG_INDENT;
  FNodeVector expandedNodes = depthFirstSearch(executionNetworkRoot->expanded);
  E_DEBUG(ENetwork, "num connected expanded nodes: " << expandedNodes.size());
  map<FractalNode*, NetworkNode*> falgoMap; // expanded → final network node

  for (int i=0; i<(int)expandedNodes.size(); i++) {
    falgoMap[expandedNodes[i]] = new NetworkNode(expandedNodes[i]->algorithm());
  }
  for (int i=0; i<(int)expandedNodes.size(); i++) {
    NetworkNode* parent = falgoMap[expandedNodes[i]];
    vector<FractalNode*> children = expandedNodes[i]->children();
    for (int j=0; j<(int)children.size(); j++) {
      E_DEBUG(ENetwork, "  -  " << parent->algorithm()->name() << " → " << falgoMap[children[j]]->algorithm()->name());
      parent->addChild(falgoMap[children[j]]);
    }
  }

  _executionNetworkRoot = falgoMap[executionNetworkRoot->expanded];

  // delete the FractalNodes which we just used temporarily for building the network
  E_DEBUG(ENetwork, "cleaning up temp visible fractal nodes");
  for (int i=0; i<(int)visibleNodes.size(); i++) delete visibleNodes[i];
  E_DEBUG(ENetwork, "cleaning up temp expanded fractal nodes");
  for (int i=0; i<(int)expandedNodes.size(); i++) delete expandedNodes[i];

  E_DEBUG_OUTDENT;
  E_DEBUG(ENetwork, "execution network ok");

}
开发者ID:spherepeer,项目名称:essentia,代码行数:57,代码来源:network.cpp

示例5: NetworkNode

NetworkNode *NetworkNode::create(
	pubnub::context *pb,
	const string &channel)
{
	NetworkNode *b = new NetworkNode();
	if (b && b->initialize(pb, channel)) {
		b->autorelease();
		return b;
	}
	CC_SAFE_DELETE(b);
	return nullptr;
}
开发者ID:pjc0247,项目名称:MagicShow,代码行数:12,代码来源:NetworkNode.cpp

示例6: depthFirstSearch

void Network::topologicalSortExecutionNetwork() {
  // Note: we don't need to do a full-fledged topological sort here, as we do not
  // have any DAG, we actually have a dependency tree. This way we can just do a
  // depth-first search, with ref-counting to account for diamond shapes in the tree.
  // this is similar to the wavefront design pattern used in parallelization

  // Using DFS here also has the advantage that it makes as much as possible use
  // of cache locality

  // 1- get all the nodes and count the number of refs they have
  NodeVector nodes = depthFirstSearch(_executionNetworkRoot);
  map<NetworkNode*, int> refs;

  // this initialization should be useless, but let's do it anyway for clarity
  for (int i=0; i<(int)nodes.size(); i++) refs[nodes[i]] = 0;

  // count the number of refs for each node
  for (int i=0; i<(int)nodes.size(); i++) {
    const NodeVector& children = nodes[i]->children();
    for (int j=0; j<(int)children.size(); j++) {
      refs[children[j]] += 1;
    }
  }

  // 2- do DFS again, manually this time and only visit node which have no refs anymore
  _toposortedNetwork.clear();

  NodeStack toVisit;
  toVisit.push(_executionNetworkRoot);
  refs[_executionNetworkRoot] = 1;

  while (!toVisit.empty()) {
    NetworkNode* currentNode = toVisit.top();
    toVisit.pop();

    if (--refs[currentNode] == 0) {
      _toposortedNetwork.push_back(currentNode->algorithm()); // keep this node, it is good

      const NodeVector& children = currentNode->children();
      for (int i=0; i<(int)children.size(); i++) {
        toVisit.push(children[i]);
      }
    }
  }

  E_DEBUG(ENetwork, "-------------------------------------------------------------------------------------------");
  for (int i=0; i<(int)_toposortedNetwork.size(); i++) {
    E_DEBUG_NONL(ENetwork, " → " << _toposortedNetwork[i]->name());
  }
  E_DEBUG(ENetwork, ""); // for adding a newline
  E_DEBUG(ENetwork, "-------------------------------------------------------------------------------------------");
}
开发者ID:spherepeer,项目名称:essentia,代码行数:52,代码来源:network.cpp

示例7: sendMessage

/**
 * Send message on the correct interface
 */
void NodeNetworkSystem::sendMessage(Message* msg) {
	if (!msg) {
		if (_DEBUG)
			cerr << "NodeNetworkSystem::sendMessage: Empty message" << endl;

		return;
	}

	NetworkNode* dst = msg->getDst();
	if (!dst) {
		if (_DEBUG)
			cerr << "NodeNetworkSystem::sendMessage: Empty destination" << endl;
		delete msg;
		return;
	}

	if (msg->getType() == MESSAGETYPE_DATA_ATC
			|| msg->getType() == MESSAGETYPE_DATA_CTA) {
		boost::mutex::scoped_lock lock(_countMutex);
		_queuedMessages++;
		_gpios[5]->setValue(BlackLib::high); //Set transmission pin
		lock.unlock();
	}

	switch (msg->getLinkType()) {
	case LINKTYPE_TCP: {
		Session* ses = dst->getSession();
		if (!ses) {
			if (_DEBUG)
				cerr << "NodeNetworkSystem::sendMessage: Empty session" << endl;
			delete msg;
			return;
		}
		ses->writeMessage(msg);
		break;
	}
	case LINKTYPE_TELOS: {
		_telosbRadioSystem->writeMessage(msg);
		break;
	}
	default: {
		if (_DEBUG)
			cout << "NodeNetworkSystem::sendMessage: Not yet implemented"
					<< endl;
		delete msg;
		break;
	}
	}

}
开发者ID:greeneyesproject,项目名称:testbed-demo,代码行数:53,代码来源:NodeNetworkSystem.cpp

示例8: GetHandoverEntity

void
NetworkManager::SelectTargetNode (UserEquipment* ue)
{
   NetworkNode* targetNode = ue->GetTargetNode ();

   if (targetNode->GetProtocolStack ()->GetRrcEntity ()->
		   GetHandoverEntity ()->CheckHandoverNeed (ue))
     {
	   NetworkNode* newTagertNode =
			   targetNode->GetProtocolStack ()->GetRrcEntity ()->
			   GetHandoverEntity ()->GetHoManager ()->m_target;

	   ue->SetTargetNode (newTagertNode);
     }
}
开发者ID:AbubakarAuwal,项目名称:lte-sim,代码行数:15,代码来源:NetworkManager.cpp

示例9: getTarget

 static std::string getTarget( NetworkNode& iNode )
 {
     std::string result;
     iNode.getTarget( result );
     
     return result;
 }
开发者ID:AWhetter,项目名称:alembic,代码行数:7,代码来源:PyIMaterial.cpp

示例10: getNodeType

    static std::string getNodeType( NetworkNode& iNode )
    {
        std::string result;
        iNode.getNodeType( result );

        return result;
    }
开发者ID:AWhetter,项目名称:alembic,代码行数:7,代码来源:PyIMaterial.cpp

示例11: GetNodeByName

bool RoutingAlg<Point, HoleType>::GreedyRouting() {
	NetworkNode<Point>	currentNode  = StartNode;
	NetworkNode<Point>	previousNode = StartNode;
	string				closestNeighborName;

	Path.push_back(StartNode);
	while(!currentNode.HasNeighbor(DestinationNode.GetName()) && currentNode.GetName() != DestinationNode.GetName()){
		if(previousNode.FindClosestNeighborToNode(DestinationNode.GetName(), closestNeighborName)
		&& NetworkPtr -> GetNodeByName(closestNeighborName, currentNode)){
			Path.push_back(currentNode);
				previousNode = currentNode;
		}
		else
			return false;
	}
	Path.push_back(DestinationNode);
	return true;
}
开发者ID:klodih,项目名称:WSNRouting,代码行数:18,代码来源:routingAlg.cpp

示例12: findCriticalPaths

void NetworkPlan::findCriticalPaths(NetworkNode* cur) {
	// Статическая переменная, инициализируется при первом вызове функции.
	// Является счётчиком путей.
	static int pathNum = 0;
	bool isFirst = true;
	NetworkNode* tmpNode = NULL;
	const vector<NetworkNode*>* nodes = cur->getOutgoingNodes();
	vector<NetworkNode*>::iterator itr;
	vector<NetworkNode*>::iterator itr2;
	int size = nodes->size();

	_critPaths->at(pathNum)->push_back(cur);

	for (int i = 0; i < size; i++) {
		tmpNode = nodes->at(i);

		if (tmpNode->getReserve() == 0) {
			if (isFirst) {
				findCriticalPaths(tmpNode);

				isFirst = false;
			} else {
				_critPaths->push_back(new vector<NetworkNode*>());

				// Получаем итератор на начало текущего пути.
				itr = _critPaths->at(pathNum)->begin();
				// Находим в пути текущий узел...
				itr2 = find(itr, _critPaths->at(pathNum)->end(), cur);

				// ... и копируем вершины в новый путь дублирующуюся часть.
				while (itr++ != (itr2 + 1)) {
					_critPaths->at(pathNum + 1)->push_back(*(itr - 1));
				}

				pathNum++;

				findCriticalPaths(tmpNode);
			}
		}
	}
}
开发者ID:ddolgushin,项目名称:study,代码行数:41,代码来源:NetworkPlanning.cpp

示例13: processPacket

void StopNodePacket::processPacket(Application* app, TCPSocket* client) const {
	NetworkNode* node = app->getNetworkNode();

	//Did we already receive this one?
	vector<Packet*> rcvPackets = node->getReceivedPackets();
	bool found = false;
	for (auto itr = rcvPackets.begin(); itr != rcvPackets.end(); itr++) {
		if (*this == **itr) {
			//the order "this then itr" is crucial, else the equality check will not work proper!
			found = true;
			break;
		}
	}

	if (!found) {
		if (targetNodeId == node->getOwnId()) {
			node->stop();
		}
		else {

			if (!app->getNetworkNode()->send(targetNodeId, this)) {
				// we don't know the target, broadcast packet
				node->sendToNeighbors(this, node->getNodeId(client));
			}
		}
	}
}
开发者ID:pascaljung,项目名称:ava,代码行数:27,代码来源:StopNodePacket.cpp

示例14: NodeInfoMsg

/**
 * A client component has connected. Notify the server this node
 */
void NodeNetworkSystem::clientConnectHandler(Session* session) {
	if (_DEBUG)
		cout << "NodeNetworkSystem::clientConnectHandler" << endl;

	NetworkNode* serverNode = NetworkNode::getNodeBySession(session);
	NetworkNode* myself = NetworkNode::getMyself();

	NodeInfoMsg* msg = new NodeInfoMsg(myself, serverNode, LINKTYPE_TCP,
			myself->getId(), myself->getAmAddr(),
			session->getSocket()->local_endpoint().address().to_string(),
			session->getSocket()->local_endpoint().port(), myself->getType());

	session->writeMessage(msg);

	if (myself->getType() == NODETYPE_CAMERA) {
		CoopInfoMsg* infoMsg = new CoopInfoMsg(NetworkNode::getMyself(),
				NetworkNode::getSink(), LINKTYPE_TCP,
				_offloadingManager->getCooperatorsIds());
		sendMessage(infoMsg);
	}

}
开发者ID:greeneyesproject,项目名称:testbed-demo,代码行数:25,代码来源:NodeNetworkSystem.cpp

示例15: getConnectionByIndex

    static dict getConnectionByIndex( NetworkNode& iNode, size_t iIndex )
    {
        std::string inputName, connectedNodeName, connectedOutputName;

        iNode.getConnection( iIndex, inputName, connectedNodeName,
                             connectedOutputName );

        dict ret;
        ret["inputName"] = inputName;
        ret["connectedNodeName"] = connectedNodeName;
        ret["connectedOuputName"] = connectedOutputName;

        return ret;
    }
开发者ID:AWhetter,项目名称:alembic,代码行数:14,代码来源:PyIMaterial.cpp


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