aaconnection.h

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

H
49
字号
#ifndef _AAConnection_h
#define _AAConnection_h

#define protect protected
#include "Common.h"

class Connection;
class Agent;
class AAConnection;
ostream &operator<<(ostream &os, const AAConnection &connection);

class AAConnection
{
protect:	
	bool mActive;
	bool mLock; /* flag for bandwidth limitation, not have meaning here, always true */

	Agent *mSource;
	Agent *mDestination;
	
	unsigned long mBandwidth;
	unsigned long mBandwidthAtoB;
	unsigned long mBandwidthBtoA;
	unsigned long mBandwidthLock; /* the maxmum bandwidth you limited, if you don't want to limit bandwidth, just gave it a large value */
	
	Connection *mConnection;
public:
	 friend ostream &operator<<(ostream &os, const AAConnection &connection);
	AAConnection(Agent *agent1, Agent *agent2);
	virtual ~AAConnection();
	
	bool isActive() const;
	unsigned long getBandwidth() const;
	unsigned long getBandwidthFrom(const Agent *agent) const;
	void setBandwidthFrom(const Agent *agent, unsigned long bandwidth);

	bool isLock() const;
	unsigned long getLockValue() const;

	virtual long long adjustBandwidth(long long value, bool flag = false);
	
	void activate(unsigned long value = UINT_MAX);
	void inactivate();
	
};

#endif

⌨️ 快捷键说明

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