Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Moteur3D::MasterTimer Class Reference

the MasterTimer class is (or should be) an "invisible" class for the application. It only cares of managing the timers' tick times. Internally it stores each timer in a TimerEntry structure that holds a pointer to the timer itself, and the absolute time it will tick. All these TimerEntry instances go into an ordered priority queue, which means only (n+1) checks are made each frame, where n is the number of timer for which the countdown is elapsed. So no matter how many timers that are currently running. More...

#include <MasterTimer.h>

List of all members.

Static Public Member Functions

static void AddTimer (Timer *timer, int delay)
 Adds a timer to the queue, with a given delay (in milliseconds).
static void CheckTimers ()
 checks the timer and trigger an event for each of them whose timer is elapsed.

Private Member Functions

 MasterTimer ()
 Constructor. Private on purpose.
 ~MasterTimer ()
 Destructor.

Private Attributes

priority_queue< TimerEntry,
deque< TimerEntry >, compareEntries
queue
 Priority queue that holds our TimerEntry instances.

Static Private Attributes

static MasterTimers_Instance
 One and only instance of that class.

Classes

struct  compareEntries
 Just a function that order our TimerEntry instances. More...
struct  TimerEntry
 TimerEntry is the internal data structure MasterTimer manipulates. There's no reason for it to be used for other purposes. More...


Detailed Description

the MasterTimer class is (or should be) an "invisible" class for the application. It only cares of managing the timers' tick times. Internally it stores each timer in a TimerEntry structure that holds a pointer to the timer itself, and the absolute time it will tick. All these TimerEntry instances go into an ordered priority queue, which means only (n+1) checks are made each frame, where n is the number of timer for which the countdown is elapsed. So no matter how many timers that are currently running.

Todo:
Separate "short period" timers from long ones in another queue ? Need to think about it and see if there's any possible gain (maybe in sort time).


Constructor & Destructor Documentation

Moteur3D::MasterTimer::MasterTimer  )  [private]
 

Constructor. Private on purpose.

Moteur3D::MasterTimer::~MasterTimer  )  [private]
 

Destructor.


Member Function Documentation

static void Moteur3D::MasterTimer::AddTimer Timer timer,
int  delay
[static]
 

Adds a timer to the queue, with a given delay (in milliseconds).

static void Moteur3D::MasterTimer::CheckTimers  )  [static]
 

checks the timer and trigger an event for each of them whose timer is elapsed.


Member Data Documentation

priority_queue< TimerEntry, deque<TimerEntry>, compareEntries> Moteur3D::MasterTimer::queue [private]
 

Priority queue that holds our TimerEntry instances.

MasterTimer* Moteur3D::MasterTimer::s_Instance [static, private]
 

One and only instance of that class.


The documentation for this class was generated from the following file:
Generated on Sat Oct 15 15:05:52 2005 for Moteur3D by  doxygen 1.4.4