timer.cpp 584 B

123456789101112131415161718192021222324252627282930313233
  1. #if defined(Hiro_Timer)
  2. mTimer::mTimer() {
  3. mObject::state.enabled = false;
  4. }
  5. auto mTimer::allocate() -> pObject* {
  6. return new pTimer(*this);
  7. }
  8. //
  9. auto mTimer::doActivate() const -> void {
  10. if(state.onActivate) return state.onActivate();
  11. }
  12. auto mTimer::interval() const -> unsigned {
  13. return state.interval;
  14. }
  15. auto mTimer::onActivate(const function<void ()>& callback) -> type& {
  16. state.onActivate = callback;
  17. return *this;
  18. }
  19. auto mTimer::setInterval(unsigned interval) -> type& {
  20. state.interval = interval;
  21. signal(setInterval, interval);
  22. return *this;
  23. }
  24. #endif