mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
refactor Agent constructor to call member variable constructors
This commit is contained in:
parent
48b57c92bd
commit
f333aaf809
2 changed files with 16 additions and 19 deletions
|
@ -32,32 +32,27 @@ int packAgentId(unsigned char *packStore, uint16_t agentId) {
|
|||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
Agent::Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentID) :
|
||||
Agent::Agent(sockaddr *publicSocket, sockaddr *localSocket, char type, uint16_t agentID) :
|
||||
_type(type),
|
||||
_agentID(agentID),
|
||||
_wakeMicrostamp(usecTimestampNow()),
|
||||
_lastHeardMicrostamp(usecTimestampNow()),
|
||||
_activeSocket(NULL),
|
||||
_bytesReceivedMovingAverage(NULL),
|
||||
_linkedData(NULL),
|
||||
_isAlive(true)
|
||||
{
|
||||
if (agentPublicSocket) {
|
||||
_publicSocket = new sockaddr;
|
||||
memcpy(_publicSocket, agentPublicSocket, sizeof(sockaddr));
|
||||
if (publicSocket) {
|
||||
_publicSocket = new sockaddr(*publicSocket);
|
||||
} else {
|
||||
_publicSocket = NULL;
|
||||
}
|
||||
|
||||
if (agentLocalSocket) {
|
||||
_localSocket = new sockaddr;
|
||||
memcpy(_localSocket, agentLocalSocket, sizeof(sockaddr));
|
||||
if (localSocket) {
|
||||
_localSocket = new sockaddr(*localSocket);
|
||||
} else {
|
||||
_localSocket = NULL;
|
||||
}
|
||||
|
||||
_type = agentType;
|
||||
_agentID = thisAgentID;
|
||||
|
||||
_wakeMicrostamp = usecTimestampNow();
|
||||
_lastHeardMicrostamp = usecTimestampNow();
|
||||
|
||||
_activeSocket = NULL;
|
||||
_linkedData = NULL;
|
||||
_bytesReceivedMovingAverage = NULL;
|
||||
}
|
||||
|
||||
Agent::Agent(const Agent &otherAgent) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
class Agent {
|
||||
public:
|
||||
Agent(sockaddr *agentPublicSocket, sockaddr *agentLocalSocket, char agentType, uint16_t thisAgentID);
|
||||
Agent(sockaddr *publicSocket, sockaddr *localSocket, char type, uint16_t agentID);
|
||||
Agent(const Agent &otherAgent);
|
||||
~Agent();
|
||||
Agent& operator=(Agent otherAgent);
|
||||
|
@ -68,11 +68,13 @@ public:
|
|||
private:
|
||||
void swap(Agent &first, Agent &second);
|
||||
|
||||
sockaddr* _publicSocket, *_localSocket, *_activeSocket;
|
||||
char _type;
|
||||
uint16_t _agentID;
|
||||
double _wakeMicrostamp;
|
||||
double _lastHeardMicrostamp;
|
||||
sockaddr* _publicSocket;
|
||||
sockaddr* _localSocket;
|
||||
sockaddr* _activeSocket;
|
||||
SimpleMovingAverage* _bytesReceivedMovingAverage;
|
||||
AgentData* _linkedData;
|
||||
bool _isAlive;
|
||||
|
|
Loading…
Reference in a new issue