[1056] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Oliver Scheuss, (C) 2007 |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[230] | 29 | // |
---|
| 30 | // C++ Interface: synchronisable |
---|
| 31 | // |
---|
[871] | 32 | // Description: |
---|
[230] | 33 | // |
---|
| 34 | // |
---|
| 35 | // Author: Oliver Scheuss, (C) 2007 |
---|
| 36 | // |
---|
| 37 | // Copyright: See COPYING file that comes with this distribution |
---|
| 38 | // |
---|
| 39 | // |
---|
[673] | 40 | #ifndef _Synchronisable_H__ |
---|
| 41 | #define _Synchronisable_H__ |
---|
[230] | 42 | |
---|
[1062] | 43 | #include "NetworkPrereqs.h" |
---|
| 44 | |
---|
[237] | 45 | #include <list> |
---|
[1021] | 46 | #include "core/OrxonoxClass.h" |
---|
[332] | 47 | |
---|
[777] | 48 | namespace network |
---|
| 49 | { |
---|
| 50 | enum variableType{ |
---|
| 51 | DATA, |
---|
| 52 | STRING, |
---|
| 53 | }; |
---|
[230] | 54 | |
---|
[777] | 55 | struct syncData{ |
---|
| 56 | int length; |
---|
| 57 | int objectID; |
---|
| 58 | int classID; |
---|
| 59 | unsigned char *data; |
---|
| 60 | }; |
---|
[237] | 61 | |
---|
[777] | 62 | typedef struct synchronisableVariable{ |
---|
| 63 | int size; |
---|
| 64 | const void *var; |
---|
| 65 | variableType type; |
---|
| 66 | }SYNCVAR; |
---|
[237] | 67 | |
---|
[230] | 68 | |
---|
[777] | 69 | /** |
---|
| 70 | * This class is the base class of all the Objects in the universe that need to be synchronised over the network |
---|
| 71 | * 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. |
---|
| 72 | * @author Oliver Scheuss |
---|
| 73 | */ |
---|
| 74 | class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{ |
---|
| 75 | public: |
---|
[230] | 76 | |
---|
[871] | 77 | virtual ~Synchronisable(); |
---|
[777] | 78 | int objectID; |
---|
| 79 | int classID; |
---|
| 80 | |
---|
| 81 | void registerVar(const void *var, int size, variableType t); |
---|
| 82 | // syncData getData(); |
---|
| 83 | syncData getData(unsigned char *mem); |
---|
| 84 | int getSize(); |
---|
| 85 | bool updateData(syncData vars); |
---|
[1021] | 86 | virtual void registerAllVariables()=0; |
---|
[777] | 87 | virtual bool create()=0; |
---|
| 88 | protected: |
---|
| 89 | Synchronisable(); |
---|
| 90 | private: |
---|
| 91 | /* bool removeObject(Iterator<Synchronisable> it);*/ |
---|
| 92 | |
---|
| 93 | std::list<SYNCVAR> syncList; |
---|
| 94 | int datasize; |
---|
| 95 | }; |
---|
[230] | 96 | } |
---|
| 97 | |
---|
[673] | 98 | #endif /* _Synchronisable_H__ */ |
---|