syncsys
Public Member Functions | Protected Member Functions

syncsys::NetEntity Class Reference

Base class for all classes which should be to synchronized by the sync system. More...

#include <SyncSystem.h>

List of all members.

Public Member Functions

virtual void Update (unsigned int update_interval=-1, unsigned int time=-1, bool add_time=false, bool update_interval_server_only=true)
 Standard update-methode for extern call of NetEntity::PerformNeededUpdates.
virtual void Update (const ChangedClientContainer &in, unsigned int update_interval=-1, unsigned int time=-1, bool add_time=false, bool update_interval_server_only=true)
 Standard update-methode for extern call of NetEntity::PerformNeededUpdates.
void ForceClientlistCheck (void)
 Force the NetEntity to update its clientlist within next NetEntity::PerformNeededUpdates-call.
void AddClients (const ChangedClientContainer &list)
 Add the clients which changed.
void AddClient (SyncServerClient *client)
 Add a single client.
void ManualRefresh (NetActionFlag f)
 provoke a (de)serialize within next NetEntity::PerformNeededUpdates-call.
unsigned int GetNetID (void) const
 Returns the unique NetID of this element.
size_t GetChangedClientSize (void) const
 Returns the size of ChangedClient. Useful for performancetests.
bool IsServerElement (void) const
 Returns if the element is a serverside element.

Protected Member Functions

 NetEntity (NetIDManager *)
 constructor for server or no network.
 NetEntity (NetEntity *, bool TakeClientListFromElement=true)
 constructor for server or no network.
 NetEntity (const ContainerConnector &, SyncClient *, bool dodeserialize)
 constructor for client.
void CopyClientListToSubElement (NetEntity *e)
 Copy the clientlist to a subelement. This is useful if you attach a element to a new parent.
void ForceRevisionOfClientVisibility (void)
 If the entity has made a change which need a revision of the "client-need-this-stuff" call this routine.
SyncClientGetClient (void) const
 Getter for Client variable to enable a clientobject to create other objects.
void PerformNeededUpdates (ChangedClientContainer *out, unsigned int update_interval=0, unsigned int time=-1, bool add_time=false, bool update_interval_server_only=true)
 Updatemethode for NetEntity.
void PerformNeededUpdates (const ChangedClientContainer &in, ChangedClientContainer *out=NULL, unsigned int update_interval=0, unsigned int time=-1, bool add_time=false, bool update_interval_server_only=true)
 Updatemethode for NetEntity.
virtual void Serialize (NetAction, helpers::NetworkBuffer &)=0
 Methode for serialize the NetEntity.
virtual void Deserialize (NetAction, helpers::NetworkBuffer &)=0
 Methode for deserialize the NetEntity.
virtual NetActionFlag ClientNeedsUpdates (SyncServerClient *client)
 callback-methode to determinate if it is needed by the client.

Detailed Description

Base class for all classes which should be to synchronized by the sync system.


Constructor & Destructor Documentation

syncsys::NetEntity::NetEntity ( NetIDManager ) [protected]

constructor for server or no network.

Register the NetEntity by the server (NetIDManager) automatically.

syncsys::NetEntity::NetEntity ( NetEntity ,
bool  TakeClientListFromElement = true 
) [protected]

constructor for server or no network.

Register the NetEntity by the server (NetIDManager) automatically. If TakeClientListFromElement is true, the instance will copy the clientlist of its parent and check it with the next NetEntity::PerformNeededUpdates-call.

syncsys::NetEntity::NetEntity ( const ContainerConnector &  ,
SyncClient ,
bool  dodeserialize 
) [protected]

constructor for client.

The ContainerConnector contains the serialised data. If dodeserialise is true, PerformNeededUpdates will be called automatically once by the system after creation of the NetEntity.


Member Function Documentation

void syncsys::NetEntity::AddClient ( SyncServerClient client) [inline]

Add a single client.

normally you use this methode only with the root NetEntity to add a new SyncServerClient to the system. Threadsafe. very slow!

void syncsys::NetEntity::AddClients ( const ChangedClientContainer &  list) [inline]

Add the clients which changed.

normally you get the list of changed clients from the parent (NetBaseClient). Threadsafe.

virtual NetActionFlag syncsys::NetEntity::ClientNeedsUpdates ( SyncServerClient client) [inline, protected, virtual]

callback-methode to determinate if it is needed by the client.

Could (and should) be overloaded to specify the behavour. Will be called if (a) a new client is passed to this instance / (b) a Client changed its version and the clientlist gets updated

Returns:
should be a combination of NetAction. Default is ALL
void syncsys::NetEntity::ManualRefresh ( NetActionFlag  f) [inline]

provoke a (de)serialize within next NetEntity::PerformNeededUpdates-call.

Call ManualRefresh if a instance attribute or children has changed so the Serialize-methode will be called within next NetEntity::PerformNeededUpdates-call.

void syncsys::NetEntity::PerformNeededUpdates ( ChangedClientContainer *  out,
unsigned int  update_interval = 0,
unsigned int  time = -1,
bool  add_time = false,
bool  update_interval_server_only = true 
) [protected]

Updatemethode for NetEntity.

Update the ClientList and checks if a (de)serialize is necessary. out should be passed to children (NetEntity).

Parameters:
out,:pointer to a ChangedClientContainer instance which should be filled an given to the children.
update_interval,:if the passed time is under this limit, PerformNeededUpdates wont do anything
time,:time (relative or absolute) used for the update_interval check
add_time,:if true the given time will be added to the internal variable. Can be used for delta times.
update_interval_server_only,:if true the update_interval affects only the server
void syncsys::NetEntity::PerformNeededUpdates ( const ChangedClientContainer &  in,
ChangedClientContainer *  out = NULL,
unsigned int  update_interval = 0,
unsigned int  time = -1,
bool  add_time = false,
bool  update_interval_server_only = true 
) [inline, protected]

Updatemethode for NetEntity.

Update the ClientList and checks if a (de)serialize is necessary. in could be get from parent (NetEntity), out should be passed to children (NetEntity).

Parameters:
in,:ChangedClientContainer instance filled from the parent PerformNeededUpdates.
out,:pointer to a ChangedClientContainer instance which should be filled an given to the children.
update_interval,:if the passed time is under this limit, PerformNeededUpdates wont do anything
time,:time (relative or absolute) used for the update_interval check
add_time,:if true the given time will be added to the internal variable. Can be used for delta times.
update_interval_server_only,:if true the update_interval affects only the server
virtual void syncsys::NetEntity::Update ( unsigned int  update_interval = -1,
unsigned int  time = -1,
bool  add_time = false,
bool  update_interval_server_only = true 
) [inline, virtual]

Standard update-methode for extern call of NetEntity::PerformNeededUpdates.

calls PerformNeededUpdates(NULL, update_interval, time, add_time). Enables a foreign element to call NetEntity::PerformNeededUpdates. Overload if you dont want this behaviour.

virtual void syncsys::NetEntity::Update ( const ChangedClientContainer &  in,
unsigned int  update_interval = -1,
unsigned int  time = -1,
bool  add_time = false,
bool  update_interval_server_only = true 
) [inline, virtual]

Standard update-methode for extern call of NetEntity::PerformNeededUpdates.

calls PerformNeededUpdates(in, NULL). Enables a foreign element to call NetEntity::PerformNeededUpdates. Overload if you dont want this behaviour.


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