connection.h
来自「模拟P2P各种网络环境的,适合新手们的学习,不错的源码.」· C头文件 代码 · 共 72 行
H
72 行
/*
* Project : P2PSimulator
*
* File Name : Connection.h
* high level directional connection between agent
*
* Author : Liu Jiang
*
* Date : 2006-3-27
*
* Log :
*/
#ifndef _Connection_h
#define _Connection_h
#define protect protected
#include "Common.h"
class Topology;
class Link;
class Agent;
class Connection;
ostream &operator<<(ostream &os, const Connection &connecion);
class Connection
{
protect:
bool mActive; /* active connection or not */
bool mLock; /* mLock is true means the bandwidth reaches its limitation */
Agent *mSource; /* source of the connection, ie initiator */
Agent *mDestination; /* destination of the connection */
vector< pair<bool, Link *> >mLink; /* all the links along the connection, including s-t link and virtual link */
unsigned long mBandwidth; /* bandwidth consumed by this connection */
unsigned long mBandwidthLock; /* bandwidth limited for this connection */
static Topology *mTopology; /* single reference to topology */
static set<Connection *> mConnection; /* all the connections in the system */
static set<Link *> mLinkAdjust; /* when activate a connection, we put the influenced links in here waiting adjusting for convenience */
unsigned long minAverageBandwidthA();
unsigned long minAverageBandwidthB();
unsigned long minAvailableBandwidth();
public:
friend ostream &operator<<(ostream &os, const Connection &connection);
Connection(Agent *agent1, Agent *agent2);
virtual ~Connection();
bool isActive();
unsigned long getBandwidth();
unsigned long getAvailableBandwidth(bool flag);
static set<Connection *> getAllConnection();
void addConnection();
void removeConnection();
void activate(unsigned long limit = UINT_MAX);
void inactivate();
virtual long long adjustBandwidth(long long value, bool internal = false);
void reallocate();
void check();
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?