luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TimerBase Class Referenceabstract

#include <Timer.h>

Inheritance diagram for TimerBase:
[legend]

Public Member Functions

 TimerBase (SingletonTimer *masterTimer)
 
virtual ~TimerBase ()
 
void start (guint intervalInMs, bool singleShot=false)
 
void stop ()
 
bool running () const
 

Detailed Description

Abstract base class containing timer functionality for Timer to use

Since Timer is a templated class, this defines the functionality in a non-templated base class. Only reason I can think of for this class existing is so that the implementation for it is not duplicated for each type of class that Timer would be templated to.

Since this class has no provisions in its public functions for adding a callback, it must be derived from to be actually used.

Constructor & Destructor Documentation

TimerBase::TimerBase ( SingletonTimer masterTimer)

Construct a timer and attach it to a parent timer

TimerBase makes SingletonTimer a bit easier to use. As such, it needs to have a SingletonTimer to attach to so it can keep track of the system clock for us.

Parameters
masterTimerSingletonTimer to attach to to use as a clock source.
TimerBase::~TimerBase ( )
virtual

Clean up memory

Since we're adding another reference to the master timer in the constructor and it's a reference counted object, it's entirely possible that once the current class instance it destroyed the master timer it's attached to can also be. This does that.

It's also declared as virtual so the correct destructor is called for derived classes.

Member Function Documentation

bool TimerBase::running ( ) const

Checks whether the timer still waiting

Returns a boolean value indicating whether or not this timer has been started and is still waiting to call a callback. For non- recurring timers, a true value means that the timer has been started but the callback has not been called yet. For recurring timers, a true value means that it has been started and not explicitly stopped.

Returns
Whether this timer is currently waiting.
void TimerBase::start ( guint  intervalInMs,
bool  singleShot = false 
)

Start this timer running and define an interval

This is where you set how often you want your callback to be called.

Parameters
intervalInMsHow often you want your callback called (in milliseconds).
singleShotWhether to only run once after intervalInMs milliseconds or to run every intervalInMs milliseconds until told to stop.
void TimerBase::stop ( )

Stop this timer from running

Cancel further running of this timer. Stops the timer from calling your callback again.


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