node.h

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

H
56
字号
#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 + =
减小字号Ctrl + -
显示快捷键?