00001 #ifndef _LCD_ELEMENT_H_
00002 #define _LCD_ELEMENT_H_
00003
00020 #include "LCDMutex.h"
00021
00022 #include <pthread.h>
00023 #include <string>
00024 #include <list>
00025 #include <map>
00026 #include <set>
00027
00035 class LCDElement
00036 {
00037 protected:
00038 static std::set<std::string> _elementsList;
00039 bool _iAmDead;
00040 static LCDMutex _elementMutex;
00041 static unsigned int _elementCounter;
00042 std::string _id;
00043 std::string _elementDel;
00044 std::string _elementAddCmd, _elementAddParam;
00045 LCDElement *_parent;
00046 class Command
00047 {
00048 public:
00049 std::string _cmd;
00050 std::string _params;
00051 Command(std::string cmd, std::string params) : _cmd(cmd), _params(params) {}
00052 };
00053 typedef std::list<Command> CommandList;
00054 typedef std::map<std::string, LCDElement *> ElementMap;
00055 ElementMap _childrenList;
00056 CommandList _commandBuffer;
00057 void setParent(LCDElement *parent);
00058 void addToList(LCDElement *elt);
00059 void removeFromList(LCDElement *elt);
00060 void notifyCreated();
00061 void notifyDestroyed();
00062 void notifyAdded();
00063
00064 public:
00065 LCDElement(const std::string &id, const std::string &addCommand, const std::string &addParam = "", LCDElement *parent=0);
00066
00074 ~LCDElement();
00075
00083 void add(LCDElement *child);
00084 virtual void sendCommand(const std::string &cmd, const std::string ¶meters = "");
00085
00092 const std::string &getId();
00093
00100 static bool exists(std::string id);
00101
00102 };
00103
00104 #endif