luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Timer< Target > Class Template Reference

#include <Timer.h>

Inheritance diagram for Timer< Target >:
[legend]
Collaboration diagram for Timer< Target >:
[legend]

Public Types

typedef bool(Target::* TimeoutFunction )()
 

Public Member Functions

 Timer (SingletonTimer *masterTimer, Target *target, TimeoutFunction function)
 
- Public Member Functions inherited from TimerBase
 TimerBase (SingletonTimer *masterTimer)
 
virtual ~TimerBase ()
 
void start (guint intervalInMs, bool singleShot=false)
 
void stop ()
 
bool running () const
 

Detailed Description

template<class Target>
class Timer< Target >

Templated timer class

Timer class which can be set up to run a method within another class. Allows timers to be set up in two steps:

  • Construct a Timer<target class> with the method to call
  • Call Timer::start() to set up the interval and start the timer running

Member Typedef Documentation

template<class Target >
typedef bool(Target::* Timer< Target >::TimeoutFunction)()

Define the type of method that can be used as a timer callback

Returns
Success of callback - false to indicate failure of the callback and cancel further recurrence of this timer, true to indicate success and that it should continue.

Constructor & Destructor Documentation

template<class Target >
Timer< Target >::Timer ( SingletonTimer< Target > *  masterTimer,
Target *  target,
TimeoutFunction  function 
)
inline

Construct a timer and set up the callback

Sets up a timer and ties it to a master SingletonTimer to use as a clock source, a target object, and the method within that object to use as a callback when the time specified in Timer::start() has elapsed.

Parameters
masterTimerSingletonTimer to use as a clock source.
targetObject containing the method to call when time elapses.
functionThe method within the given class to call when time elapses.

The documentation for this class was generated from the following file: