#include <src/network/synchronisable/Synchronisable.h>
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 Synchronisable * | fabricate (uint8_t *&mem, uint8_t mode=0x0) |
static unsigned int | getNumberOfDeletedObject () |
static Synchronisable * | getSynchronisable (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 |
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] |
Constructor: Initializes all Variables and sets the right objectID
References classID, creatorID, dataSize_, orxonox::BaseObject::getCreator(), getObjectID(), orxonox::Host::isServer(), orxonox::Priority::Normal, objectID, orxonox::OBJECTID_UNKNOWN, objectMap_, objectMode_, RegisterRootObject, orxonox::Host::running(), and setPriority().
bool orxonox::Synchronisable::deleteObject | ( | uint32_t | objectID | ) | [static] |
Finds and deletes the Synchronisable with the appropriate objectID
objectID | objectID of the Synchronisable |
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)
id | gamestate id |
References objectMode_, state_, and syncList.
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
mem | pointer to where the appropriate data is located | |
mode | defines the mode, how the data should be loaded |
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
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 |
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] |
Referenced by orxonox::packet::DeleteObjects::fetchIDs().
uint32_t orxonox::Synchronisable::getObjectID | ( | ) | const [inline] |
Referenced by orxonox::Engine::addToSpaceShip(), orxonox::Test::call2(), orxonox::Pawn::doFire(), orxonox::WorldEntity::notifyBeingAttached(), orxonox::CollisionShape::notifyBeingAttached(), orxonox::GametypeInfo::sendAnnounceMessage(), orxonox::GametypeInfo::sendDeathMessage(), orxonox::GametypeInfo::sendKillMessage(), orxonox::PongBall::setBats(), orxonox::ControllableEntity::setPlayer(), orxonox::PlayerInfo::startControl(), Synchronisable(), and orxonox::PlayerInfo::updateGametypeInfo().
unsigned int orxonox::Synchronisable::getPriority | ( | ) | const [inline] |
Referenced by orxonox::TrafficControl::insertinClientListPerm().
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
id | id of the gamestate | |
mode | same as getData |
References dataSize_, doSync(), orxonox::SynchronisableHeader::getSize(), state_, and stringList.
Referenced by getData().
Synchronisable * orxonox::Synchronisable::getSynchronisable | ( | uint32_t | objectID | ) | [static] |
This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
objectID | objectID of the Synchronisable |
References objectMap_.
Referenced by orxonox::PongBall::applyBats(), orxonox::NetworkMemberFunction< T >::call(), deleteObject(), fabricate(), orxonox::TrafficControl::insertinClientListPerm(), orxonox::PlayerInfo::networkcallback_changedcontrollableentityID(), orxonox::PlayerInfo::networkcallback_changedgtinfoID(), orxonox::ControllableEntity::networkcallback_changedplayerID(), orxonox::WorldEntity::networkcallback_parentChanged(), orxonox::Engine::networkcallback_shipID(), orxonox::CollisionShape::parentChanged(), and orxonox::packet::Gamestate::spreadData().
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
mem | pointer to the bytestream |
References orxonox::SynchronisableHeader::getObjectID(), orxonox::SynchronisableHeader::isDataAvailable(), and objectID.
static uint32_t orxonox::Synchronisable::popDeletedObject | ( | ) | [inline, static] |
Referenced by orxonox::packet::DeleteObjects::fetchIDs().
void orxonox::Synchronisable::registerVariable | ( | Quaternion & | variable, | |
uint8_t | mode, | |||
NetworkCallbackBase * | cb, | |||
bool | bidirectional | |||
) | [inline] |
References orxonox::MT_Type::Quaternion, and registerVariable().
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] |
References orxonox::mbool::getMemory(), and registerVariable().
void orxonox::Synchronisable::registerVariable | ( | Vector4 & | variable, | |
uint8_t | mode, | |||
NetworkCallbackBase * | cb, | |||
bool | bidirectional | |||
) | [inline] |
References registerVariable(), and orxonox::MT_Type::Vector4.
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] |
References registerVariable(), and orxonox::MT_Type::Vector3.
void orxonox::Synchronisable::registerVariable | ( | const Vector3 & | variable, | |
uint8_t | mode, | |||
NetworkCallbackBase * | cb, | |||
bool | bidirectional | |||
) | [inline] |
References registerVariable().
_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] |
References orxonox::MT_Type::ColourValue, and registerVariable().
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.
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
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)
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] |
This function takes a bytestream and loads the data into the registered variables
mem | pointer to the bytestream | |
mode | same as in getData |
References classID, COUT, creatorID, orxonox::SynchronisableHeader::getClassID(), orxonox::SynchronisableHeader::getCreatorID(), orxonox::SynchronisableHeader::getDataSize(), orxonox::SynchronisableHeader::getObjectID(), orxonox::SynchronisableHeader::getSize(), orxonox::SynchronisableHeader::isDataAvailable(), objectID, state_, and syncList.
Referenced by fabricate(), and orxonox::packet::Gamestate::spreadData().
friend class packet::Gamestate [friend] |
bool orxonox::Synchronisable::backsync_ [private] |
uint32_t orxonox::Synchronisable::classID [private] |
Referenced by fabricate(), getData(), Synchronisable(), and updateData().
uint32_t orxonox::Synchronisable::creatorID [private] |
Referenced by fabricate(), getData(), Synchronisable(), and updateData().
uint32_t orxonox::Synchronisable::dataSize_ [private] |
Referenced by getSize(), registerVariable(), and Synchronisable().
std::queue< uint32_t > orxonox::Synchronisable::deletedObjects_ [static, private] |
Referenced by ~Synchronisable().
unsigned int orxonox::Synchronisable::objectFrequency_ [private] |
uint32_t orxonox::Synchronisable::objectID [private] |
Referenced by fabricate(), getData(), isMyData(), Synchronisable(), updateData(), and ~Synchronisable().
std::map< uint32_t, Synchronisable * > orxonox::Synchronisable::objectMap_ [static, private] |
Referenced by fabricate(), getSynchronisable(), Synchronisable(), and ~Synchronisable().
int orxonox::Synchronisable::objectMode_ [private] |
Referenced by doSync(), setObjectMode(), Synchronisable(), and ~Synchronisable().
uint8_t orxonox::Synchronisable::state_ = 0x1 [static, private] |
Reimplemented in orxonox::MultiStateEngine, and orxonox::TeamBaseMatchBase.
Referenced by doSync(), getData(), getSize(), registerVariable(), setClient(), and updateData().
std::vector<SynchronisableVariableBase*> orxonox::Synchronisable::stringList [private] |
Referenced by getSize(), registerVariable(), and ~Synchronisable().
std::vector<SynchronisableVariableBase*> orxonox::Synchronisable::syncList [private] |
Referenced by doSync(), getData(), registerVariable(), updateData(), and ~Synchronisable().