/* */ #ifndef _D_BT_RUNTIME_H_ #define _D_BT_RUNTIME_H_ #include "common.h" #include "SharedHandle.h" #define MIN_PEERS 15 class BtRuntime { private: long long int uploadLengthAtStartup; int port; bool halt; int connections; int cuidCounter; public: BtRuntime(): uploadLengthAtStartup(0), port(0), halt(false), connections(0), cuidCounter(0) {} ~BtRuntime() {} long long int getUploadLengthAtStartup() const { return uploadLengthAtStartup; } void setUploadLengthAtStartup(long long int length) { this->uploadLengthAtStartup = length; } void setListenPort(int port) { this->port = port; } int getListenPort() const { return port; } bool isHalt() const { return halt; } void setHalt(bool halt) { this->halt = halt; } int getConnections() const { return connections; } void increaseConnections() { connections++; } void decreaseConnections() { connections--; } bool lessThanMinPeer() const { return connections < MIN_PEERS; } bool lessThanEqMinPeer() const { return connections <= MIN_PEERS; } int getNewCuid() { return ++cuidCounter; } }; typedef SharedHandle BtRuntimeHandle; #endif // _D_BT_RUNTIME_H_