#ifndef _BLOCK_H_ #define _BLOCK_H_ #include "modelbahn.h" #include "server.h" #define BLOCK_F_OFF 0x0001 #define BLOCK_F_SHORT 0x0010 #define BLOCK_F_LONG 0x0020 #define BLOCK_F_ENDSTATION 0x0040 #define BLOCK_F_SPEEDLIMIT 0x0100 struct s_Block { char name[REFERENCENAME_LEN]; char s_pos_1[REFERENCENAME_LEN]; char s_neg_1[REFERENCENAME_LEN]; int flags; char lockedby[REFERENCENAME_LEN]; // element locked by locreference (only set by server, not by JSON/Webinterface) } typedef Block; class Blocks { private: Block *blocks; int max; int changed; pthread_mutex_t mtx; int Lock(); int UnLock(); // not thread safe JSONParse _GetJSON(int idx); public: Blocks(); ~Blocks(); bool IsChanged() { return changed; } void ClearChanged() { changed = 0; }; int Change(Block *se); int Delete(string name); JSONParse GetJSON(string name); void GetJSONAll(JSONParse *json); Block GetBlockFromJSON(JSONParse *j); int SetOff(string name); int Clear(string name); }; #endif