/*! * @file synchronizeable_var.h * @brief Definition of SynchronizeableVar */ #ifndef _SYNCHRONIZEABLE_VAR_H #define _SYNCHRONIZEABLE_VAR_H #include #include "netdefs.h" class SynchronizeableVar { public: SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = 0, int priority = 0 ); virtual ~SynchronizeableVar(); /** * check if synchronizeable wants to be informed on changes * @return true if synchronizeable wants to be informed on changes */ inline bool beWatched(){ return this->bWatched; } virtual int writeToBuf( byte * buf, int maxLength ); virtual int readFromBuf( byte * buf, int maxLength ); /** * check for permission to write * @return true if you can write */ inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; } /** * get variable name * @return name */ inline std::string getName(){ return name; } /** * set variable name * @param name new name */ inline void setName( std::string name ) { this->name = name; } private: bool bWatched; //!< true if synchronizeable wants to be informed on changes protected: void * ptrIn; //!< pointer to data (read) void * ptrOut; //!< pointer to data (write) int length; //!< data length int permission; //!< who is allowed to change this var int priority; //!< priority assigned to var int real_priority; //!< priority assigned to var, increased every time not sent std::string name; //!< variable name (for debugging) }; #endif /* _PROTO_CLASS_H */