Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/Synchronisable.h @ 1342

Last change on this file since 1342 was 1293, checked in by scheusso, 17 years ago

merged changes from input & camera & network branch into trunk

File size: 3.0 KB
Line 
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
29//
30// C++ Interface: synchronisable
31//
32// Description:
33//
34//
35// Author:  Oliver Scheuss, (C) 2007
36//
37// Copyright: See COPYING file that comes with this distribution
38//
39//
40#ifndef _Synchronisable_H__
41#define _Synchronisable_H__
42
43#include "NetworkPrereqs.h"
44
45#include <list>
46#include "core/OrxonoxClass.h"
47
48namespace network
49{
50  enum variableType{
51    DATA,
52    STRING,
53  };
54
55  struct syncData{
56    int length;
57    int objectID;
58    int classID;
59    unsigned char *data;
60  };
61
62  typedef struct synchronisableVariable{
63    int size;
64    int mode; // this determines in which direction the variable gets synchronised
65    void *var;
66    variableType type;
67  }SYNCVAR;
68
69
70  /**
71  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
72   * Every class, t
73  int mode;hat 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.
74  * @author Oliver Scheuss
75  */
76  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
77  public:
78
79    virtual ~Synchronisable();
80    int objectID;
81    int classID;
82
83    void registerVar(void *var, int size, variableType t, int mode=1);
84    //  syncData getData();
85    syncData getData(unsigned char *mem);
86    int getSize();
87    bool updateData(syncData vars);
88    void setBacksync(bool sync);
89    bool getBacksync();
90    virtual void registerAllVariables()=0;
91    virtual bool create()=0;
92    static void setClient(bool b);
93  protected:
94    Synchronisable();
95  private:
96    /*  bool removeObject(Iterator<Synchronisable> it);*/
97
98    std::list<synchronisableVariable *> *syncList;
99    int datasize;
100    static int state_; // detemines wheter we are server (default) or client
101    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
102  };
103}
104
105#endif /* _Synchronisable_H__ */
Note: See TracBrowser for help on using the repository browser.