Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h @ 7459

Last change on this file since 7459 was 7459, checked in by rennerc, 18 years ago

finished some SynchronizeableVars classes

File size: 2.3 KB
Line 
1/*!
2 * @file synchronizeable_var.h
3 * @brief Definition of SynchronizeableVar
4*/
5
6#ifndef _SYNCHRONIZEABLE_VAR_H
7#define _SYNCHRONIZEABLE_VAR_H
8
9#include <string>
10#include "netdefs.h"
11
12class SynchronizeableVar {
13
14  public:
15    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = 0, int priority = 0 );
16    virtual ~SynchronizeableVar();
17   
18    /**
19     * check if synchronizeable wants to be informed on changes
20     * @return true if synchronizeable wants to be informed on changes
21     */
22    inline bool beWatched(){ return this->bWatched; }
23   
24    /**
25     * write var data to byte buffer
26     * @param buf pointer to write to
27     * @param maxLength writeToBuf will not write more than maxLength bytes
28     * @return number bytes written
29     */
30    virtual int writeToBuf( byte * buf, int maxLength ) = 0;
31   
32    /**
33     * read var data from byte buffer
34     * @param buf pointer to read from
35     * @param maxLength readFromBuf will not read more than maxLength bytes
36     * @return number bytes read
37     */
38    virtual int readFromBuf( byte * buf, int maxLength ) = 0;
39   
40    /**
41     * check if writeToBuf will return the same size every time
42     * @return true if same size every time
43     */
44    virtual bool hasStaticSize() = 0;
45   
46    /**
47     * check for permission to write
48     * @return true if you can write
49     */
50    inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; }
51   
52    /**
53     * get variable name
54     * @return name
55     */
56    inline std::string getName(){ return name; }
57   
58    /**
59     * set variable name
60     * @param name new name
61     */
62    inline void setName( std::string name ) { this->name = name; }
63
64
65  private:
66    bool bWatched;      //!< true if synchronizeable wants to be informed on changes
67
68  protected:
69    void * ptrIn;       //!< pointer to data (read)
70    void * ptrOut;      //!< pointer to data (write)
71    int length;         //!< data length
72    int permission;     //!< who is allowed to change this var
73    int priority;       //!< priority assigned to var
74    int real_priority;  //!< priority assigned to var, increased every time not sent
75   
76   
77    std::string name;    //!< variable name (for debugging)
78
79};
80
81#endif /* _PROTO_CLASS_H */
Note: See TracBrowser for help on using the repository browser.