Rev | Line | |
---|
[230] | 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 | // |
---|
[247] | 12 | #ifndef NETWORK_SYNCHRONISABLE_H |
---|
| 13 | #define NETWORK_SYNCHRONISABLE_H |
---|
[230] | 14 | |
---|
[237] | 15 | #include <list> |
---|
| 16 | |
---|
[230] | 17 | namespace network { |
---|
| 18 | |
---|
[237] | 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 | |
---|
[230] | 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: |
---|
[237] | 40 | Synchronisable(); |
---|
[230] | 41 | |
---|
[237] | 42 | ~Synchronisable(); |
---|
| 43 | int objectID; |
---|
| 44 | int classID; |
---|
| 45 | |
---|
| 46 | void registerVar(const void *var, int size); |
---|
| 47 | syncData getData(); |
---|
[247] | 48 | syncData getData(unsigned char *mem); |
---|
| 49 | int getSize(); |
---|
[237] | 50 | bool updateData(syncData vars); |
---|
| 51 | virtual void registerAllVariables(); |
---|
[230] | 52 | |
---|
[237] | 53 | private: |
---|
| 54 | std::list<SYNCVAR> syncList; |
---|
[247] | 55 | int datasize; |
---|
[230] | 56 | }; |
---|
| 57 | |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.