protocol.h

来自「模拟P2P各种网络环境的,适合新手们的学习,不错的源码.」· C头文件 代码 · 共 50 行

H
50
字号
#ifndef __PROTOCOL_H
#define __PROTOCOL_H
#include <vector>
using namespace std;
class Agent;
class Topology;
class Protocol{
public:
	vector<Agent*> mAgents;
	unsigned int 	mAgentNum;
	Topology* mTopology;

public:
	Protocol(void){
		mAgentNum =0;
		mAgents.clear();
	}
	~Protocol(void);

    	void setTopology(Topology* topology){
			if( topology == NULL)
				return;
			mTopology = topology;
      }

      void setAgentNum(unsigned int num){
		if( mAgentNum < num)
			mAgents.resize(num);
	  	mAgentNum = num;
      }
      bool setAgent(Agent* p, unsigned int num){
	  	if( p == NULL || num > mAgentNum )
			return false;
	  	mAgents[num] = p;
		return true;
      }
      Agent* getAgent(unsigned int num){
	  	if(  num > mAgentNum)
			return NULL;
		return mAgents[num];
      }
	/*
	**retrive the delay between agent (ID1:source) and agent(ID2:destination)
	*/
      double getAgentDelay( unsigned int ID1, unsigned int ID2);
	

};
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?