LightWrap++
AC++wrapperfortheLightWave3DSDK
timer.h
Go to the documentation of this file.
1 #ifndef LWPP_TIMER_H
2 #define LWPP_TIMER_H
3 
4 #include <lwpp/global.h>
5 #include <lwtimer.h>
6 
7 namespace lwpp
8 {
10 
14  class Timer : public GlobalBase<LWTimer>
15  {
16  template <typename T>
17  static int CB_TimerProc(void *data)
18  {
19  if (data)
20  {
21  T *func = static_cast<T *>(data);
22  return (func->TimerEvent() ? 1 : 0);
23  }
24  return 1; // remove event
25  }
26  public:
31  template <typename T>
32  void addTimer(T *host, unsigned long interval)
33  {
34  globPtr->timerAdd(CB_TimerProc<T>, host, interval);
35  }
52  template <typename T>
53  void removeTimer(T *host, unsigned long interval = 0)
54  {
55  globPtr->timerRemove(CB_TimerProc<T>, interval);
56  }
57  };
58 } // namespace lwpp
59 
60 #endif // LWPP_TIMER_H