Go to the documentation of this file.00001
00002
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 #ifndef TIMER_H
00028 #define TIMER_H
00029
00030 #include <time.h>
00031
00032 #include "GpCoreToolsDLLExport.h"
00033
00034 namespace GpCoreTools {
00035
00036 class GPCORETOOLS_EXPORT Timer
00037 {
00038 public:
00039 Timer();
00040 virtual ~Timer();
00041
00042 void start();
00043 void stop();
00044
00045 bool isRunning() {return _queued;}
00046
00047 int interval() const {return _interval;}
00048 void setInterval(int i) {_interval=i;}
00049
00050 void setTimeout();
00051 int timeout() const;
00052 bool after(Timer * o) const;
00053
00054 void printDebug();
00055
00056 virtual bool exec()=0;
00057 private:
00058 friend class EventLoop;
00059
00060 int _interval;
00061 timespec _timeout;
00062
00063 class QueueItem
00064 {
00065 public:
00066 QueueItem(Timer * t) {_timer=t;}
00067 ~QueueItem() {if(_timer) _timer->stop();}
00068
00069 Timer * timer() {return _timer;}
00070 void detach() {_timer=0;}
00071 private:
00072 Timer * _timer;
00073 };
00074 QueueItem * _queued;
00075 };
00076
00077 }
00078
00079 #endif // TIMER_H