orxonox::Synchronisable Class Reference

#include <src/network/synchronisable/Synchronisable.h>

Inheritance diagram for orxonox::Synchronisable:

orxonox::OrxonoxClass orxonox::CollisionShape orxonox::GlobalShader orxonox::Info orxonox::Item orxonox::Level orxonox::Scene orxonox::Test orxonox::WorldEntity

List of all members.

Public Member Functions

uint32_t getClassID () const
unsigned int getCreatorID () const
uint32_t getObjectID () const
unsigned int getPriority () const
template<>
_NetworkExport void registerVariable (Quaternion &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (const Quaternion &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (mbool &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (Vector4 &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (const Vector4 &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (Vector3 &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (const Vector3 &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (Vector2 &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (const Vector2 &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (ColourValue &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (const ColourValue &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
template<>
_NetworkExport void registerVariable (std::string &variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
virtual ~Synchronisable ()

Static Public Member Functions

static bool deleteObject (uint32_t objectID)
static Synchronisablefabricate (uint8_t *&mem, uint8_t mode=0x0)
static unsigned int getNumberOfDeletedObject ()
static SynchronisablegetSynchronisable (uint32_t objectID)
static uint32_t popDeletedObject ()
static void setClient (bool b)

Protected Member Functions

template<class T>
void registerVariable (T &variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false)
void setObjectMode (uint8_t mode)
void setPriority (unsigned int freq)
 Synchronisable (BaseObject *creator)

Private Member Functions

bool doSync (int32_t id, uint8_t mode=0x0)
uint32_t getData (uint8_t *&men, int32_t id, uint8_t mode=0x0)
uint32_t getSize (int32_t id, uint8_t mode=0x0)
bool isMyData (uint8_t *mem)
bool updateData (uint8_t *&mem, uint8_t mode=0x0, bool forceCallback=false)

Private Attributes

bool backsync_
uint32_t classID
uint32_t creatorID
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


Detailed Description

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.
Author:
Oliver Scheuss

Constructor & Destructor Documentation

orxonox::Synchronisable::~Synchronisable (  )  [virtual]

Destructor: Delete all callback objects and remove objectID from the objectMap_

References deletedObjects_, orxonox::Identifier::isCreatingHierarchy(), orxonox::Host::isServer(), objectID, objectMap_, objectMode_, orxonox::Host::running(), stringList, and syncList.

orxonox::Synchronisable::Synchronisable ( BaseObject creator  )  [protected]


Member Function Documentation

bool orxonox::Synchronisable::deleteObject ( uint32_t  objectID  )  [static]

Finds and deletes the Synchronisable with the appropriate objectID

Parameters:
objectID objectID of the Synchronisable
Returns:
true/false

References getSynchronisable().

Referenced by orxonox::packet::DeleteObjects::process().

bool orxonox::Synchronisable::doSync ( int32_t  id,
uint8_t  mode = 0x0 
) [private]

This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)

Parameters:
id gamestate id
Returns:
true/false

References objectMode_, state_, and syncList.

Referenced by getData(), and getSize().

Synchronisable * orxonox::Synchronisable::fabricate ( uint8_t *&  mem,
uint8_t  mode = 0x0 
) [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

Parameters:
mem pointer to where the appropriate data is located
mode defines the mode, how the data should be loaded
Returns:
pointer to the newly created synchronisable

References ClassByID, classID, COUT, creatorID, orxonox::SynchronisableHeader::getClassID(), orxonox::SynchronisableHeader::getCreatorID(), orxonox::SynchronisableHeader::getDataSize(), orxonox::SynchronisableHeader::getObjectID(), getSynchronisable(), orxonox::SynchronisableHeader::isDataAvailable(), objectID, orxonox::OBJECTID_UNKNOWN, objectMap_, and updateData().

Referenced by orxonox::packet::Gamestate::spreadData().

uint32_t orxonox::Synchronisable::getClassID (  )  const [inline]

unsigned int orxonox::Synchronisable::getCreatorID (  )  const [inline]

uint32_t orxonox::Synchronisable::getData ( uint8_t *&  mem,
int32_t  id,
uint8_t  mode = 0x0 
) [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

Parameters:
mem pointer to allocated memory with enough size
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 (not recommended) 0x3: bidirectional
Returns:
true: if !doSync or if everything was successfully saved

References ClassByID, classID, COUT, creatorID, doSync(), orxonox::OrxonoxClass::getIdentifier(), orxonox::Identifier::getName(), orxonox::Identifier::getNetworkID(), getSize(), orxonox::SynchronisableHeader::getSize(), objectID, orxonox::SynchronisableHeader::setClassID(), orxonox::SynchronisableHeader::setCreatorID(), orxonox::SynchronisableHeader::setDataAvailable(), orxonox::SynchronisableHeader::setDataSize(), orxonox::SynchronisableHeader::setObjectID(), state_, and syncList.

static unsigned int orxonox::Synchronisable::getNumberOfDeletedObject (  )  [inline, static]

uint32_t orxonox::Synchronisable::getObjectID (  )  const [inline]

unsigned int orxonox::Synchronisable::getPriority (  )  const [inline]

uint32_t orxonox::Synchronisable::getSize ( int32_t  id,
uint8_t  mode = 0x0 
) [private]

This function returns the total amount of bytes needed by getData to save the whole content of the variables

Parameters:
id id of the gamestate
mode same as getData
Returns:
amount of bytes

References dataSize_, doSync(), orxonox::SynchronisableHeader::getSize(), state_, and stringList.

Referenced by getData().

Synchronisable * orxonox::Synchronisable::getSynchronisable ( uint32_t  objectID  )  [static]

bool orxonox::Synchronisable::isMyData ( uint8_t *  mem  )  [private]

This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones

Parameters:
mem pointer to the bytestream

References orxonox::SynchronisableHeader::getObjectID(), orxonox::SynchronisableHeader::isDataAvailable(), and objectID.

static uint32_t orxonox::Synchronisable::popDeletedObject (  )  [inline, static]

void orxonox::Synchronisable::registerVariable ( Quaternion &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

void orxonox::Synchronisable::registerVariable ( const Quaternion &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

References registerVariable().

void orxonox::Synchronisable::registerVariable ( mbool variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

void orxonox::Synchronisable::registerVariable ( Vector4 &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

void orxonox::Synchronisable::registerVariable ( const Vector4 &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

References registerVariable().

void orxonox::Synchronisable::registerVariable ( Vector3 &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

void orxonox::Synchronisable::registerVariable ( const Vector3 &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

References registerVariable().

template<>
_NetworkExport void orxonox::Synchronisable::registerVariable ( Vector2 &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

void orxonox::Synchronisable::registerVariable ( const Vector2 &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

References registerVariable().

void orxonox::Synchronisable::registerVariable ( ColourValue &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

void orxonox::Synchronisable::registerVariable ( const ColourValue &  variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

References registerVariable().

void orxonox::Synchronisable::registerVariable ( std::string variable,
uint8_t  mode,
NetworkCallbackBase cb,
bool  bidirectional 
) [inline]

References stringList, and syncList.

template<class T>
void orxonox::Synchronisable::registerVariable ( T &  variable,
uint8_t  mode = 0x1,
NetworkCallbackBase cb = 0,
bool  bidirectional = false 
) [inline, protected]

References dataSize_, state_, and syncList.

Referenced by registerVariable(), orxonox::WorldEntity::registerVariables(), orxonox::StaticEntity::registerVariables(), orxonox::PongBat::registerVariables(), orxonox::PongBall::registerVariables(), orxonox::Planet::registerVariables(), orxonox::Spectator::registerVariables(), orxonox::SpaceShip::registerVariables(), orxonox::Pawn::registerVariables(), orxonox::ParticleEmitter::registerVariables(), orxonox::MovableEntity::registerVariables(), orxonox::Model::registerVariables(), orxonox::Light::registerVariables(), orxonox::FadingBillboard::registerVariables(), orxonox::ExplosionChunk::registerVariables(), orxonox::ControllableEntity::registerVariables(), orxonox::Billboard::registerVariables(), orxonox::BigExplosion::registerVariables(), orxonox::Backlight::registerVariables(), orxonox::LightningGunProjectile::registerVariables(), orxonox::Test::registerVariables(), orxonox::Scene::registerVariables(), orxonox::Level::registerVariables(), orxonox::MultiStateEngine::registerVariables(), orxonox::Engine::registerVariables(), orxonox::PlayerInfo::registerVariables(), orxonox::HumanPlayer::registerVariables(), orxonox::GametypeInfo::registerVariables(), orxonox::GlobalShader::registerVariables(), orxonox::SphereCollisionShape::registerVariables(), orxonox::PlaneCollisionShape::registerVariables(), orxonox::ConeCollisionShape::registerVariables(), orxonox::CollisionShape::registerVariables(), and orxonox::BoxCollisionShape::registerVariables().

void orxonox::Synchronisable::setClient ( bool  b  )  [static]

This function sets the internal mode for synchronisation

Parameters:
b true if this object is located on a client or on a server

References state_.

Referenced by orxonox::Client::establishConnection(), and orxonox::packet::Welcome::process().

void orxonox::Synchronisable::setObjectMode ( uint8_t  mode  )  [protected]

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)

Parameters:
mode same as in registerVar

References objectMode_.

Referenced by orxonox::Camera::Camera(), orxonox::CameraPosition::CameraPosition(), orxonox::HumanPlayer::networkcallback_clientIDchanged(), orxonox::ControllableEntity::removePlayer(), orxonox::ControllableEntity::setPlayer(), orxonox::SpawnPoint::SpawnPoint(), orxonox::Test::Test(), orxonox::MultiStateEngine::tick(), orxonox::Trigger::Trigger(), orxonox::WeaponSlot::WeaponSlot(), and orxonox::WorldEntityCollisionShape::WorldEntityCollisionShape().

void orxonox::Synchronisable::setPriority ( unsigned int  freq  )  [inline, protected]

bool orxonox::Synchronisable::updateData ( uint8_t *&  mem,
uint8_t  mode = 0x0,
bool  forceCallback = false 
) [private]


Friends And Related Function Documentation

friend class packet::Gamestate [friend]


Member Data Documentation

std::queue< uint32_t > orxonox::Synchronisable::deletedObjects_ [static, private]

Referenced by ~Synchronisable().

std::map< uint32_t, Synchronisable * > orxonox::Synchronisable::objectMap_ [static, private]

uint8_t orxonox::Synchronisable::state_ = 0x1 [static, private]


The documentation for this class was generated from the following files:

Generated on Tue Jul 28 16:23:07 2009 for Orxonox by  doxygen 1.5.6