You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
799 B
52 lines
799 B
#ifndef TIMER_HPP
|
|
#define TIMER_HPP
|
|
|
|
|
|
#include <time.h> // timer_t
|
|
#include <map>
|
|
|
|
class TimerUser
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void timerExpired() = 0;
|
|
virtual void timerDestroyed() = 0;
|
|
|
|
virtual ~TimerUser() {}
|
|
|
|
}; // class TimerUser
|
|
|
|
|
|
class Timer
|
|
{
|
|
|
|
public:
|
|
|
|
Timer();
|
|
|
|
virtual ~Timer();
|
|
|
|
timer_t createTimer( TimerUser *m_timerUser,
|
|
clockid_t clockId = CLOCK_MONOTONIC );
|
|
|
|
bool setTimer( timer_t timerId,
|
|
const time_t interval_sec,
|
|
const long interval_nsec = 0,
|
|
const time_t initExpr_sec = 0,
|
|
const long initExpr_nsec = 0 );
|
|
|
|
bool stopTimer( timer_t timerId );
|
|
|
|
|
|
private:
|
|
|
|
typedef std::map<timer_t, TimerUser*> TimerUserMap;
|
|
|
|
TimerUserMap m_timerUsers;
|
|
|
|
}; // class Timer
|
|
|
|
|
|
#endif // TIMER_HPP
|