Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/synchronizeable.h @ 9319

Last change on this file since 9319 was 9295, checked in by patrick, 18 years ago

extended the handshake structure to support synchronization of proxy server addresses

File size: 3.4 KB
RevLine 
[5523]1/*!
[7954]2 * @file synchronizeable.h
[5550]3    \brief interface for all classes that have to be synchronized
[5547]4 */
[5523]5
[5547]6#ifndef _SYNCHRONIZEABLE_H
7#define _SYNCHRONIZEABLE_H
[5523]8
[5997]9#include "base_object.h"
[5547]10#include "netdefs.h"
[6341]11#include "converter.h"
[7954]12#include "vector.h"
13#include "quaternion.h"
14#include "synchronizeable_var/synchronizeable_var.h"
15#include "synchronizeable_var/synchronizeable_vector.h"
16#include "synchronizeable_var/synchronizeable_quaternion.h"
17#include "synchronizeable_var/synchronizeable_string.h"
18#include "synchronizeable_var/synchronizeable_int.h"
19#include "synchronizeable_var/synchronizeable_float.h"
20#include "synchronizeable_var/synchronizeable_bool.h"
21#include "synchronizeable_var/synchronizeable_uint.h"
[9295]22#include "synchronizeable_var/synchronizeable_ip.h"
[5547]23
[5997]24
25#include <vector>
26#include <list>
27
28//State constants: They have to be of the form 2^n
29#define STATE_SERVER 1
30
[7954]31struct StateHistoryEntry
32{
33  int             stateId;
34  byte *          data;
35  int             dataLength;
36  std::list<int>  sizeList;
[6815]37};
38
[7954]39typedef std::list<StateHistoryEntry*> StateHistory;
[6815]40
[7954]41typedef std::vector<StateHistory> UserStateHistory;
[6959]42
[7954]43typedef std::vector<SynchronizeableVar*> SyncVarList;
[6815]44
[6139]45class NetworkStream;
[5997]46
[5581]47class Synchronizeable : virtual public BaseObject
[6695]48{
49
[5804]50  public:
[5996]51    Synchronizeable();
[6695]52    virtual ~Synchronizeable();
[5523]53
[9272]54//     void setIsServer( bool isServer );
55//     bool isServer();
[6695]56
[7954]57    virtual void varChangeHandler( std::list<int> & id );
58
59    virtual int getStateDiff( int userId, byte* data, int maxLength, int stateId, int fromStateId, int priorityTH );
60    virtual int setStateDiff( int userId, byte* data, int length, int stateId, int fromStateId );
61    virtual void cleanUpUser( int userId );
62    virtual void handleSentState( int userId, int stateId, int fromStateId );
63    virtual void handleRecvState( int userId, int stateId, int fromStateId );
[9272]64
[7954]65    void registerVar( SynchronizeableVar * var );
66    int registerVarId( SynchronizeableVar * var );
67
[6341]68    inline void setUniqueID( int id ){ uniqueID = id; }
[6695]69    inline int  getUniqueID() const { return uniqueID; }
[5547]70
[6139]71    inline int getOwner(){ return owner; }
72    inline void setOwner(int owner){ this->owner = owner; }
73
[7954]74    /** @returns true if this Synchronizeable wants to be synchronized over network */
[6695]75    inline bool beSynchronized() { return this->bSynchronize; }
76    /** @param bSynchronize sets the Synchronizeable to be sunchronized or not */
77    inline void setSynchronized(bool bSynchronize) { this->bSynchronize = bSynchronize; }
[6139]78
[6695]79    inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; }
80    inline NetworkStream* getNetworkStream() { return this->networkStream; }
[6139]81
82
[6695]83  protected:
[7954]84    NetworkStream*    networkStream;  //!< reference network stream we are connected to
[9272]85//     int               state;
[6139]86
[6695]87  private:
[7954]88    int               uniqueID;       //!< unique id assigned to synchronizeable
89    int               mLeafClassId;   //!< store leafClassId to send via states
90    int               owner;          //!< hostId of owner ( 0 if none / server )
91    bool              bSynchronize;   //!< do we need beeing synchronized?
[5547]92
[7954]93    SyncVarList       syncVarList;    //!< list containing variables to synchronize
[6139]94
[7954]95    UserStateHistory  sentStates;     //!< store already sent states to create diffs from, offset corresponds to the user id
96    UserStateHistory  recvStates;     //!< store recieved states to apply diffs, offset corresponds to the user id
97
[6695]98};
[5548]99#endif /* _SYNCHRONIZEABLE_H */
Note: See TracBrowser for help on using the repository browser.