#ifndef _TIMER_H #define _TIMER_H #pragma interface #undef hz class Timer { unsigned long target; // system tick count to call timerEvent at Timer *nextTimer; char active; public: Timer() { active = 0; } virtual void timerEvent() = 0; static unsigned long ticks(); // check timers, return system clock ticks static void wait(struct timeval &); void timer(unsigned long ticks); void timer(int t) { timer((unsigned long)t); } void timer(double t) { timer((unsigned long)t); } static const double hz; // ticks per second // true if target occurred before tick count int before(unsigned long ticks) const { return ((ticks - target) & 0x80000000L) == 0; } virtual ~Timer() { timer(0UL); } }; #endif