[7444] | 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 | |
---|
| 12 | class 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 | virtual int writeToBuf( byte * buf, int maxLength ); |
---|
| 25 | virtual int readFromBuf( byte * buf, int maxLength ); |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * check for permission to write |
---|
| 29 | * @return true if you can write |
---|
| 30 | */ |
---|
| 31 | inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; } |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * get variable name |
---|
| 35 | * @return name |
---|
| 36 | */ |
---|
| 37 | inline std::string getName(){ return name; } |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * set variable name |
---|
| 41 | * @param name new name |
---|
| 42 | */ |
---|
| 43 | inline void setName( std::string name ) { this->name = name; } |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | private: |
---|
| 47 | bool bWatched; //!< true if synchronizeable wants to be informed on changes |
---|
| 48 | |
---|
| 49 | protected: |
---|
| 50 | void * ptrIn; //!< pointer to data (read) |
---|
| 51 | void * ptrOut; //!< pointer to data (write) |
---|
| 52 | int length; //!< data length |
---|
| 53 | int permission; //!< who is allowed to change this var |
---|
| 54 | int priority; //!< priority assigned to var |
---|
| 55 | int real_priority; //!< priority assigned to var, increased every time not sent |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | std::string name; //!< variable name (for debugging) |
---|
| 59 | |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | #endif /* _PROTO_CLASS_H */ |
---|