12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef TIMER_H
- #define TIMER_H
- template <class T>
- class Timer
- {
- public:
- Timer();
- void start();
- void stop(){m_isRunning = false;}
- bool running()const {return m_isRunning;}
- bool expired(T msPeriod);
- T elapsed();
- bool expired_cont(T msPeriod);
- protected:
- T started()const {return m_started;}
- private:
- bool m_isRunning;
- T m_started;
- };
- #if __cplusplus>=201103L
- using LongTimer = Timer<unsigned long>;
- #else
- typedef Timer<unsigned long> LongTimer;
- #endif
- #if __cplusplus>=201103L
- using ShortTimer = Timer<unsigned short>;
- #else
- typedef Timer<unsigned short> ShortTimer;
- #endif
- #endif
|