Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/Synchronisable.h @ 1699

Last change on this file since 1699 was 1699, checked in by scheusso, 16 years ago

some missing files

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