/*! * @file connection_monitor.h \brief interface for all classes that have to be synchronized */ #ifndef _SYNCHRONIZEABLE_H #define _SYNCHRONIZEABLE_H #include "base_object.h" #include "netdefs.h" #include #include //State constants: They have to be of the form 2^n #define STATE_SERVER 1 #define STATE_OUTOFSYNC 2 class Synchronizeable : virtual public BaseObject { public: Synchronizeable(const char* name); Synchronizeable(); ~Synchronizeable(); virtual void writeBytes(const byte* data, int length); virtual int readBytes(byte* data, int maxLength, int * reciever); virtual void writeDebug() const; virtual void readDebug() const; void setIsServer( bool isServer ); void setIsOutOfSync( bool outOfSync ); bool isServer(); bool isOutOfSync(); void setUniqueId( int id ){ uniqueID = id; } int getUniqueID() const { return uniqueID; }; void requestSync( int hostID ){ this->synchronizeRequests.push_back( hostID ); } inline int getOwner(){ return owner; } inline void setOwner(int owner){ this->owner = owner; } private: int uniqueID; //static std::vector classList; int owner; int hostID; int state; std::list synchronizeRequests; }; #endif /* _SYNCHRONIZEABLE_H */