00001 // Timer.hpp 00002 // 00003 // created: June 6, 2011 00004 // 00005 // Mit "-lrt" linken!! 00006 // 00007 00008 #ifndef TIMER_HPP 00009 #define TIMER_HPP 00010 00011 #include "../BasicDatatypes.hpp" 00012 #include "Time.hpp" 00013 00015 00024 class Timer 00025 { 00026 public: 00028 00029 Timer(); 00030 00032 virtual ~Timer (); 00033 00035 void restart(); 00036 00037 // Starts the watchdog timer, with the given timeout interval. 00038 // Note that no action is taken, but the timer has to be queried using 00039 // isElapsed(). 00040 void startWatchdog(TimeDuration watchdogTime); 00041 00042 // Returns true if the given timeout interval has elapsed. 00043 bool isElapsed(); 00044 00045 // Restarts the timer. 00046 void reset(); 00047 00048 // Returns the elapsed time in seconds since the timer was started or restarted. 00049 TimeDuration elapsed () const; 00050 // double elapsed () const; 00051 00053 UINT32 elapsedMilliseconds () const; 00054 00056 UINT32 elapsedMicroseconds () const; 00057 00058 UINT32 elapsedMillisecondsSinceLastCall(); 00059 UINT32 elapsedMicrosecondsSinceLastCall(); 00060 00061 // static timeval now(); // Returns the current time 00062 00063 private: 00064 Time m_startTime; 00065 TimeDuration m_watchdogTime; // Zeitintervall des Watchdog 00066 }; 00067 00068 #endif // TIMER_HPP