mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
disallow Agent copying
This commit is contained in:
parent
2c17f04d40
commit
12bf23e4c8
3 changed files with 7 additions and 68 deletions
|
@ -55,67 +55,6 @@ Agent::Agent(sockaddr* publicSocket, sockaddr* localSocket, char type, uint16_t
|
|||
}
|
||||
}
|
||||
|
||||
Agent::Agent(const Agent &otherAgent) :
|
||||
_type(otherAgent._type),
|
||||
_agentID(otherAgent._agentID),
|
||||
_wakeMicrostamp(otherAgent._wakeMicrostamp),
|
||||
_lastHeardMicrostamp(otherAgent._lastHeardMicrostamp),
|
||||
_isAlive(otherAgent._isAlive)
|
||||
{
|
||||
if (otherAgent._publicSocket) {
|
||||
_publicSocket = new sockaddr(*otherAgent._localSocket);
|
||||
} else {
|
||||
_publicSocket = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._localSocket) {
|
||||
_localSocket = new sockaddr(*otherAgent._localSocket);
|
||||
} else {
|
||||
_localSocket = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._activeSocket == otherAgent._publicSocket) {
|
||||
_activeSocket = _publicSocket;
|
||||
} else if (otherAgent._activeSocket == otherAgent._localSocket) {
|
||||
_activeSocket = _localSocket;
|
||||
} else {
|
||||
_activeSocket = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._linkedData) {
|
||||
_linkedData = otherAgent._linkedData->clone();
|
||||
} else {
|
||||
_linkedData = NULL;
|
||||
}
|
||||
|
||||
if (otherAgent._bytesReceivedMovingAverage != NULL) {
|
||||
_bytesReceivedMovingAverage = new SimpleMovingAverage(100);
|
||||
memcpy(_bytesReceivedMovingAverage, otherAgent._bytesReceivedMovingAverage, sizeof(SimpleMovingAverage));
|
||||
} else {
|
||||
_bytesReceivedMovingAverage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Agent& Agent::operator=(Agent otherAgent) {
|
||||
swap(*this, otherAgent);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Agent::swap(Agent &first, Agent &second) {
|
||||
using std::swap;
|
||||
|
||||
swap(first._isAlive, second._isAlive);
|
||||
swap(first._publicSocket, second._publicSocket);
|
||||
swap(first._localSocket, second._localSocket);
|
||||
swap(first._activeSocket, second._activeSocket);
|
||||
swap(first._type, second._type);
|
||||
swap(first._linkedData, second._linkedData);
|
||||
swap(first._agentID, second._agentID);
|
||||
swap(first._wakeMicrostamp, second._wakeMicrostamp);
|
||||
swap(first._lastHeardMicrostamp, second._lastHeardMicrostamp);
|
||||
swap(first._bytesReceivedMovingAverage, second._bytesReceivedMovingAverage);
|
||||
}
|
||||
|
||||
Agent::~Agent() {
|
||||
delete _publicSocket;
|
||||
delete _localSocket;
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
class Agent {
|
||||
public:
|
||||
Agent(sockaddr* publicSocket, sockaddr* localSocket, char type, uint16_t agentID);
|
||||
Agent(const Agent &otherAgent);
|
||||
~Agent();
|
||||
Agent& operator=(Agent otherAgent);
|
||||
|
||||
bool operator==(const Agent& otherAgent);
|
||||
|
||||
bool matches(sockaddr* otherPublicSocket, sockaddr* otherLocalSocket, char otherAgentType);
|
||||
|
@ -66,7 +65,9 @@ public:
|
|||
|
||||
static void printLog(Agent const&);
|
||||
private:
|
||||
void swap(Agent &first, Agent &second);
|
||||
// privatize copy and assignment operator to disallow Agent copying
|
||||
Agent(const Agent &otherAgent);
|
||||
Agent& operator=(Agent otherAgent);
|
||||
|
||||
char _type;
|
||||
uint16_t _agentID;
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
#define hifi_AgentData_h
|
||||
|
||||
class AgentData {
|
||||
public:
|
||||
virtual ~AgentData() = 0;
|
||||
virtual int parseData(unsigned char* sourceBuffer, int numBytes) = 0;
|
||||
virtual AgentData* clone() const = 0;
|
||||
public:
|
||||
virtual ~AgentData() = 0;
|
||||
virtual int parseData(unsigned char* sourceBuffer, int numBytes) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue