Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Examples

LCDSensor.h

00001 #ifndef _LCD_SENSOR_H_
00002 #define _LCD_SENSOR_H_
00003 
00021 #include "../api/LCDWidget.h"
00022 #include <map>
00023 #include <vector>
00024 #include <pthread.h>
00025 
00026 class LCDWidgetTimeOut
00027 {
00028  public:
00029   std::string _widgetId;
00030   int _timeOut;
00031   LCDWidget *_widget;
00032   ::pthread_t _thread;
00033   LCDWidgetTimeOut()
00034   {
00035     _thread = (::pthread_t)-1;
00036   }
00037   bool isValid()
00038   {
00039     return (_thread != (::pthread_t)-1);
00040   }
00041 };
00042 
00043 extern "C" void *updateWhenChanged(void *);
00044 extern "C" void *updateEach(void *);
00045 
00055 class LCDSensor
00056 {
00057  private:
00058   bool _exist;
00059   bool _onChangeThreadStarted;
00060 
00061   typedef void*(*ThreadFunction)(void*);
00062 
00063   typedef std::map<std::string, LCDWidget *> WidgetList;
00064   typedef std::map<std::string, LCDWidgetTimeOut> WidgetTimeOutList;
00065 
00066   ::pthread_t _onChangeThread;
00067   WidgetList _onChangeList;
00068   WidgetTimeOutList _onTimeOutList;
00069 
00070  public:
00071   static const int MAX_CMD_RESULT_LINE_SIZE;
00072   LCDSensor();
00073   ~LCDSensor();
00074   bool exists();
00075   const LCDWidgetTimeOut &getThreadWidgetInfo(const ::pthread_t &thread);
00082   virtual void waitForChange() = 0;
00091   virtual std::string getCurrentValue() = 0;
00100   std::string intToString(int value);
00101 
00110   std::string executeCommand(const std::string &cmd);
00111   void fireChanged();
00119   void addOnChangeWidget(LCDWidget *widget);
00128   void addOnTimeOutWidget(LCDWidget *widget, int timeOut);
00135   void removeOnChangeWidget(LCDWidget *widget);
00142   void removeOnChangeWidget(std::string id);
00149   void removeOnTimeOutWidget(LCDWidget *widget);
00156   void removeOnTimeOutWidget(std::string id);
00157 };
00158 
00159 #endif

Generated on Wed Aug 4 19:39:09 2004 for LCDApi by doxygen 1.3.6