00001 #ifndef __TIMEOUT_H_INCLUDED__
00002 #define __TIMEOUT_H_INCLUDED__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <cstring.h>
00042 #include <time.h>
00043
00044 #include <watchble.h>
00045
00046
00047 namespace Monitor {
00048 namespace Utility {
00049
00053 class Timeout : public Watchable
00054 {
00055 public:
00064 Timeout(const CallbackBase& newWatch,
00065 unsigned newPeriod,
00066 const string& newName = "");
00067
00074 Timeout(unsigned newPeriod,
00075 const string& newName = "");
00076
00081 virtual ~Timeout();
00082
00083
00087 int
00088 operator==(const Timeout& other);
00089
00090
00097 void
00098 reset(unsigned newPeriod = 0);
00099
00103 int
00104 hasExpired() const;
00105
00112 int
00113 run();
00114
00118 const string&
00119 getTimeoutName() const;
00120
00121 private:
00125 unsigned period;
00126
00130 clock_t endTime;
00131
00135 Timeout() {;}
00136
00140 Timeout(const Timeout&) {;}
00141
00142
00146 Timeout&
00147 operator=(const Timeout&) {return *this;}
00148
00152 virtual int
00153 canRun();
00154
00158 void
00159 expire();
00160
00161 string timeoutName;
00162 int expiredFlag;
00163 };
00164
00165 };
00166 };
00167
00168 #endif // __TIMEOUT_H_INCLUDED__