Orxonox
0.0.5 Codename: Arcturus
|
This class is the base class of all the Objects in the universe that need to be synchronised over the network Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/network/synchronisable/Synchronisable.h>
Public Member Functions | |
virtual | ~Synchronisable () |
Destructor: Delete all callback objects and remove objectID_ from the objectMap_. More... | |
uint32_t | getClassID () const |
unsigned int | getContextID () const |
uint32_t | getNrOfVariables () |
uint32_t | getObjectID () const |
unsigned int | getPriority () const |
uint8_t | getSyncMode () const |
uint32_t | getVarSize (VariableID ID) |
template<> | |
_NetworkExport void | registerVariable (std::string &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) |
template<> | |
void | registerVariable (std::string &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) |
void | setSyncMode (uint8_t mode) |
This function sets the synchronisation mode of the object If set to 0x0 variables will not be synchronised at all If set to 0x1 variables will only be synchronised to the client If set to 0x2 variables will only be synchronised to the server If set to 0x3 variables will be synchronised bidirectionally (only if set so in registerVar) More... | |
template<> | |
_NetworkExport void | unregisterVariable (std::string &variable) |
template<> | |
void | unregisterVariable (std::string &variable) |
Public Member Functions inherited from orxonox::OrxonoxInterface | |
OrxonoxInterface () | |
Public Member Functions inherited from orxonox::Configurable | |
Configurable () | |
void | setConfigValues () |
Function to collect the SetConfigValue-macro calls. More... | |
Public Member Functions inherited from orxonox::Listable | |
Listable () | |
Constructor: Allocates space in the element list. More... | |
Listable (Context *context) | |
Constructor: Allocates space in the element list and assigns the context. More... | |
virtual | ~Listable () |
Destructor: Removes the object from the object-lists. More... | |
Context * | getContext () const |
void | setContext (Context *context) |
Changes the context. More... | |
void | unregisterObject () |
Removes this object from the object-lists. More... | |
Public Member Functions inherited from orxonox::Identifiable | |
Identifiable () | |
Constructor: Sets the default values. More... | |
virtual | ~Identifiable () |
ORX_FORCEINLINE void * | getDerivedPointer (unsigned int classID) |
Returns a valid pointer of any derived type that is registered in the class hierarchy. More... | |
template<class T > | |
ORX_FORCEINLINE T * | getDerivedPointer (unsigned int classID) |
Version of getDerivedPointer with template. More... | |
template<class T > | |
ORX_FORCEINLINE const T * | getDerivedPointer (unsigned int classID) const |
Const version of getDerivedPointer with template. More... | |
Identifier * | getIdentifier () const |
Returns the Identifier of the object. More... | |
bool | isA (const Identifier *identifier) |
Returns true if the object's class is of the given type or a derivative. More... | |
template<class B > | |
bool | isA (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is of the given type or a derivative. More... | |
bool | isA (const Identifiable *object) |
Returns true if the object's class is of the given type or a derivative. More... | |
bool | isChildOf (const Identifier *identifier) |
Returns true if the object's class is a child of the given type. More... | |
template<class B > | |
bool | isChildOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a child of the given type. More... | |
bool | isChildOf (const Identifiable *object) |
Returns true if the object's class is a child of the given type. More... | |
bool | isDirectChildOf (const Identifier *identifier) |
Returns true if the object's class is a direct child of the given type. More... | |
template<class B > | |
bool | isDirectChildOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isDirectChildOf (const Identifiable *object) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isDirectParentOf (const Identifier *identifier) |
Returns true if the object's class is a direct parent of the given type. More... | |
template<class B > | |
bool | isDirectParentOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a direct parent of the given type. More... | |
bool | isDirectParentOf (const Identifiable *object) |
Returns true if the object's class is a direct child of the given type. More... | |
bool | isExactlyA (const Identifier *identifier) |
Returns true if the object's class is exactly of the given type. More... | |
template<class B > | |
bool | isExactlyA (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is exactly of the given type. More... | |
bool | isExactlyA (const Identifiable *object) |
Returns true if the object's class is exactly of the given type. More... | |
bool | isParentOf (const Identifier *identifier) |
Returns true if the object's class is a parent of the given type. More... | |
template<class B > | |
bool | isParentOf (const SubclassIdentifier< B > *identifier) |
Returns true if the object's class is a parent of the given type. More... | |
bool | isParentOf (const Identifiable *object) |
Returns true if the object's class is a parent of the given type. More... | |
Public Member Functions inherited from orxonox::Destroyable | |
Destroyable () | |
Constructor: Sets the default values. More... | |
virtual | ~Destroyable () |
Destructor: Notifies all DestructionListener (for example weak pointers) that this object is being deleted. More... | |
void | destroy () |
Deletes the object if no strong pointers point to this object. More... | |
void | destroyLater () |
Works like destroy() but doesn't destroy the object until the current tick has ended. More... | |
unsigned int | getReferenceCount () const |
Returns the number of strong pointers that point to this object. More... | |
Static Public Member Functions | |
static bool | deleteObject (uint32_t objectID_) |
Finds and deletes the Synchronisable with the appropriate objectID_. More... | |
static Synchronisable * | fabricate (uint8_t *&mem, uint8_t mode=0x0) |
This function fabricated a new synchrnisable (and children of it), sets calls updateData and create After calling this function the mem pointer will be increased by the size of the needed data. More... | |
static unsigned int | getNumberOfDeletedObject () |
static Synchronisable * | getSynchronisable (uint32_t objectID_) |
This function looks up the objectID_ in the objectMap_ and returns a pointer to the right Synchronisable. More... | |
static uint32_t | popDeletedObject () |
static void | setClient (bool b) |
This function sets the internal mode for synchronisation. More... | |
Protected Member Functions | |
Synchronisable (Context *context) | |
Constructor: Initializes all Variables and sets the right objectID_. More... | |
uint32_t | findContextID (Context *context) |
Returns the id of the context. More... | |
template<class T > | |
void | registerVariable (T &variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false) |
template<class T > | |
void | registerVariable (std::set< T > &variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false) |
void | setPriority (unsigned int freq) |
template<class T > | |
void | unregisterVariable (T &var) |
Protected Member Functions inherited from orxonox::Destroyable | |
virtual void | preDestroy () |
This virtual function is called if destroy() is called and no StrongPtr points to this object. More... | |
Private Member Functions | |
bool | doReceive (uint8_t mode) |
This function determines, wheter the object should accept data from the bytestream (according to its syncmode/direction) More... | |
bool | doSync (uint8_t mode=0x0) |
This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction) More... | |
uint32_t | getData (uint8_t *&mem, std::vector< uint32_t > &sizes, int32_t id, uint8_t mode) |
This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID_ and classID_ to the given memory takes a pointer to already allocated memory (must have at least getSize bytes length) structure of the bitstream: |totalsize,objectID_,classID_,var1,var2,string1_length,string1,var3,...| length of varx: size saved int syncvarlist. More... | |
uint32_t | getSize (int32_t id, uint8_t mode=0x0) |
This function returns the total amount of bytes needed by getData to save the whole content of the variables. More... | |
void | setClassID (uint32_t id) |
void | setObjectID (uint32_t id) |
bool | updateData (uint8_t *&mem, uint8_t mode=0x0, bool forceCallback=false) |
This function takes a bytestream and loads the data into the registered variables. More... | |
Private Attributes | |
bool | backsync_ |
uint32_t | classID_ |
uint32_t | contextID_ |
uint32_t | dataSize_ |
unsigned int | objectFrequency_ |
uint32_t | objectID_ |
int | objectMode_ |
std::vector< SynchronisableVariableBase * > | stringList_ |
std::vector< SynchronisableVariableBase * > | syncList_ |
Static Private Attributes | |
static std::queue< uint32_t > | deletedObjects_ |
static std::map< uint32_t, Synchronisable * > | objectMap_ |
static uint8_t | state_ =0x1 |
Friends | |
class | packet::Gamestate |
This class is the base class of all the Objects in the universe that need to be synchronised over the network Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list.
|
virtual |
Destructor: Delete all callback objects and remove objectID_ from the objectMap_.
|
protected |
Constructor: Initializes all Variables and sets the right objectID_.
|
static |
Finds and deletes the Synchronisable with the appropriate objectID_.
objectID_ | objectID_ of the Synchronisable |
|
private |
This function determines, wheter the object should accept data from the bytestream (according to its syncmode/direction)
mode | Synchronisation mode (toclient, toserver or bidirectional) |
|
private |
This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)
mode | Synchronisation mode (toclient, toserver or bidirectional) |
|
static |
This function fabricated a new synchrnisable (and children of it), sets calls updateData and create After calling this function the mem pointer will be increased by the size of the needed data.
mem | pointer to where the appropriate data is located |
mode | defines the mode, how the data should be loaded |
|
protected |
Returns the id of the context.
If the context is not Synchronisable, it moves on to its parent, recursively.
|
inline |
|
inline |
|
private |
This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID_ and classID_ to the given memory takes a pointer to already allocated memory (must have at least getSize bytes length) structure of the bitstream: |totalsize,objectID_,classID_,var1,var2,string1_length,string1,var3,...| length of varx: size saved int syncvarlist.
mem | pointer to allocated memory with enough size |
sizes | vector containing sizes of all objects in gamestate (to be appended) |
id | gamestateid of the gamestate to be saved (important for priorities) |
mode | defines the direction in which the data will be send/received 0x1: server->client 0x2: client->server 0x3: bidirectional |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
private |
This function returns the total amount of bytes needed by getData to save the whole content of the variables.
id | id of the gamestate |
mode | same as getData |
|
static |
This function looks up the objectID_ in the objectMap_ and returns a pointer to the right Synchronisable.
objectID_ | objectID_ of the Synchronisable |
|
inline |
|
inline |
|
inlinestatic |
|
protected |
|
protected |
_NetworkExport void orxonox::Synchronisable::registerVariable | ( | std::string & | variable, |
uint8_t | mode, | ||
NetworkCallbackBase * | cb, | ||
bool | bidirectional | ||
) |
void orxonox::Synchronisable::registerVariable | ( | std::string & | variable, |
uint8_t | mode, | ||
NetworkCallbackBase * | cb, | ||
bool | bidirectional | ||
) |
|
inlineprivate |
|
static |
This function sets the internal mode for synchronisation.
b | true if this object is located on a client or on a server |
|
inlineprivate |
|
inlineprotected |
void orxonox::Synchronisable::setSyncMode | ( | uint8_t | mode | ) |
This function sets the synchronisation mode of the object If set to 0x0 variables will not be synchronised at all If set to 0x1 variables will only be synchronised to the client If set to 0x2 variables will only be synchronised to the server If set to 0x3 variables will be synchronised bidirectionally (only if set so in registerVar)
mode | same as in registerVar |
|
protected |
_NetworkExport void orxonox::Synchronisable::unregisterVariable | ( | std::string & | variable | ) |
void orxonox::Synchronisable::unregisterVariable | ( | std::string & | variable | ) |
|
private |
This function takes a bytestream and loads the data into the registered variables.
mem | pointer to the bytestream |
mode | same as in getData |
forceCallback | this makes updateData call each callback |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
private |
|
private |