| Line |   | 
|---|
| 1 | // | 
|---|
| 2 | // C++ Interface: synchronisable | 
|---|
| 3 | // | 
|---|
| 4 | // Description:  | 
|---|
| 5 | // | 
|---|
| 6 | // | 
|---|
| 7 | // Author:  Oliver Scheuss, (C) 2007 | 
|---|
| 8 | // | 
|---|
| 9 | // Copyright: See COPYING file that comes with this distribution | 
|---|
| 10 | // | 
|---|
| 11 | // | 
|---|
| 12 | #ifndef NETWORK_SYNCHRONISABLE_H | 
|---|
| 13 | #define NETWORK_SYNCHRONISABLE_H | 
|---|
| 14 |  | 
|---|
| 15 | #include <list> | 
|---|
| 16 |  | 
|---|
| 17 | namespace network { | 
|---|
| 18 |  | 
|---|
| 19 |    | 
|---|
| 20 | struct syncData{ | 
|---|
| 21 |   int length; | 
|---|
| 22 |   int classID; | 
|---|
| 23 |   int objectID; | 
|---|
| 24 |   unsigned char *data; | 
|---|
| 25 | }; | 
|---|
| 26 |  | 
|---|
| 27 | typedef struct synchronisableVariable{ | 
|---|
| 28 |   int size; | 
|---|
| 29 |   const void *var; | 
|---|
| 30 | }SYNCVAR; | 
|---|
| 31 |  | 
|---|
| 32 |    | 
|---|
| 33 | /** | 
|---|
| 34 |  * This class is the base class of all the Objects in the universe that need to be synchronised over the network | 
|---|
| 35 |  * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list. | 
|---|
| 36 |  * @author Oliver Scheuss | 
|---|
| 37 | */ | 
|---|
| 38 | class Synchronisable{ | 
|---|
| 39 | public: | 
|---|
| 40 |   Synchronisable(); | 
|---|
| 41 |  | 
|---|
| 42 |   ~Synchronisable(); | 
|---|
| 43 |   int objectID; | 
|---|
| 44 |   int classID; | 
|---|
| 45 |      | 
|---|
| 46 |   void registerVar(const void *var, int size); | 
|---|
| 47 |   syncData getData(); | 
|---|
| 48 |   syncData getData(unsigned char *mem); | 
|---|
| 49 |   int getSize(); | 
|---|
| 50 |   bool updateData(syncData vars); | 
|---|
| 51 |   virtual void registerAllVariables(); | 
|---|
| 52 |  | 
|---|
| 53 | private: | 
|---|
| 54 |   std::list<SYNCVAR> syncList; | 
|---|
| 55 |   int datasize; | 
|---|
| 56 | }; | 
|---|
| 57 |  | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | #endif | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.