Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7444 was 7444, checked in by rennerc, 18 years ago

new network system implemented. yet with a lot of empty function bodys

File size: 2.7 KB
Line 
1/*!
2 * @file synchronizeable.h
3    \brief interface for all classes that have to be synchronized
4 */
5
6#ifndef _SYNCHRONIZEABLE_H
7#define _SYNCHRONIZEABLE_H
8
9#include "base_object.h"
10#include "netdefs.h"
11#include "converter.h"
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"
22
23
24#include <vector>
25#include <list>
26
27//State constants: They have to be of the form 2^n
28#define STATE_SERVER 1
29
30enum {
31  PERMISSION_OWNER = 1,
32  PERMISSION_ALL   = 2
33};
34
35typedef std::vector<SynchronizeableVar> SyncVarList;
36
37class NetworkStream;
38
39class Synchronizeable : virtual public BaseObject
40{
41
42  public:
43    Synchronizeable();
44    virtual ~Synchronizeable();
45
46    void setIsServer( bool isServer );
47    bool isServer();
48   
49    virtual void varChangeHandler( std::list<int> & id );
50   
51    int getStateDiff( int userId, byte* data, int maxLength, int stateId, int priorityTH );
52    bool setStateDiff( int userId, byte* data, int length, int stateId );
53   
54    void registerVar( SynchronizeableVar * var );
55    int registerVarId( SynchronizeableVar * var );
56   
57    inline void setUniqueID( int id ){ uniqueID = id; }
58    inline int  getUniqueID() const { return uniqueID; }
59    inline int getHostID() { return this->hostID; }
60
61    inline int getOwner(){ return owner; }
62    inline void setOwner(int owner){ this->owner = owner; }
63
64    /** @returns true if this Synchronizeable has to be synchronized over network */
65    inline bool beSynchronized() { return this->bSynchronize; }
66    /** @param bSynchronize sets the Synchronizeable to be sunchronized or not */
67    inline void setSynchronized(bool bSynchronize) { this->bSynchronize = bSynchronize; }
68
69    inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; }
70    inline NetworkStream* getNetworkStream() { return this->networkStream; }
71
72
73  protected:
74    NetworkStream*    networkStream;  //!< reference network stream we are connected to
75    int               state;
76
77  private:
78    int               uniqueID;       //!< unique id assigned to synchronizeable
79    int               owner;          //!< hostId of owner ( 0 if none / server )
80    int               hostID;         //!< my own host id
81    bool              bSynchronize;   //!< do we need beeing synchronized?
82
83};
84#endif /* _SYNCHRONIZEABLE_H */
Note: See TracBrowser for help on using the repository browser.