⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protocol.h

📁 模拟P2P各种网络环境的,适合新手们的学习,不错的源码.
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -