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

📄 node.h

📁 模拟P2P各种网络环境的,适合新手们的学习,不错的源码.
💻 H
字号:
#ifndef _Node_h
#define _Node_h

#include "Common.h"
#include "NodeProperty.h"

class Agent;
class Link;
class SimEvent;

class Node;
ostream &operator<<(ostream &os, const Node &node);

class Node
{
private:
	int mAID; /* which autonomous system this node belongs to; */
	int mNodeID; /* node id; */
	
	bool mActive;
	
	set<int> mLinkSet; /* link list attached to this node */
	list<Agent *> mAgentList; /* agent list attached to this node; */
	map<int, Link *> mVLinkMap; /* virtual link list */
	
	NodeProperty mNodeProperty; /* additional information of this node; */
public:
	friend ostream &operator<<(ostream &os, const Node &node);
	void reset(); /* reset mActive and mAgentList; */
	Node();
	void setType(int type);
	int getType() const;
	void setAID(int id);
	int getAID() const;
	void setID(int id);
	int getID() const;
	void setLinkTo(int id);
	bool haveLinkTo(int id) const;

	Link *getVLink(Agent *agent);
	set<int> getLinkSet() const;
	
	void setProperty(const NodeProperty &property);
	NodeProperty getProperty() const;
	
	list<Agent *> getAgentList() const;

	bool isActive() const;
	bool handle(SimEvent *event);
	void attach(Agent *agent);
	void detach(Agent *agent);
};

#endif

⌨️ 快捷键说明

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