Lugre::cTimer Class Reference

#include <lugre_timer.h>

List of all members.

Public Types

enum  { kListenerEvent_Timeout, kListenerEvent_Interval, kListenerEvent_FrameInterval }
 eventcodes for cListener More...
enum  { kMaxFrameIntervalExp = 24 }

Public Member Functions

 cTimer (const size_t iTime)
virtual ~cTimer ()
void StartFrame (const size_t iTime)
cTimerRegistrationRegisterTimeoutListener (cListener *pListener, const size_t iTimeOut, void *userdata=0)
 listener will be notified ONCE in about iTimeOut milliseconds (1000=1sec) after this call, but not during this frame
cTimerRegistrationRegisterIntervalListener (cListener *pListener, const size_t iInterval, void *userdata=0)
cTimerRegistrationRegisterFrameIntervalListener (cListener *pListener, const size_t iFrameIntervalExp, void *userdata=0)
bool IsCurFrameInInterval (const size_t iInterval)

Static Public Member Functions

static cTimerGetSingletonPtr (cTimer *pSetSingleton=0)
static size_t GetIntervalStart (const size_t iInterval)
static bool IsFrameInInterval (const size_t iInterval, const size_t iFrame)

Public Attributes

std::multiset
< cTimerRegistration
*, cTimerRegistrationCompare
mlTimeouts
std::list< cTimerRegistration * > mlIntervals
std::vector< std::list
< cTimerRegistration * > * > 
mlFrameIntervals

Static Public Attributes

static size_t miTimeSinceLastFrame = 1
static size_t miLastFrameTime = 0
static size_t miCurFrameNum = 0
static float mfPhysStepTime = 0.0

Classes

class  cTimerRegistration
 commonly used by Timeout, Interval and FrameInterval More...
struct  cTimerRegistrationCompare


Detailed Description

manages timing in applications using frames. similar to cListenable all times are in milliseconds (1000=1second) iFrameInterval is for calling every n frames, must be a power of two (1,2,4,8,..) RegisterFrameIntervalListener takes an EXPONENT, i.e. passing 3 as iFrameIntervalExp will result in getting called every 2^3 = 1<<3 = 8 frames frame intervals are distributed a bit to avoid bumps in the framerate, e.g. 2 and 4 will never occur on the same frame

Definition at line 40 of file lugre_timer.h.


Member Enumeration Documentation

anonymous enum

eventcodes for cListener

Enumerator:
kListenerEvent_Timeout 
kListenerEvent_Interval 
kListenerEvent_FrameInterval 

Definition at line 47 of file lugre_timer.h.

anonymous enum

Enumerator:
kMaxFrameIntervalExp 

Definition at line 52 of file lugre_timer.h.


Constructor & Destructor Documentation

Lugre::cTimer::cTimer ( const size_t  iTime  ) 

Definition at line 14 of file lugre_timer.cpp.

References miLastFrameTime, and PROFILE.

Lugre::cTimer::~cTimer (  )  [virtual]

Definition at line 19 of file lugre_timer.cpp.

References PROFILE.


Member Function Documentation

static cTimer* Lugre::cTimer::GetSingletonPtr ( cTimer pSetSingleton = 0  )  [inline, static]

void Lugre::cTimer::StartFrame ( const size_t  iTime  ) 

cTimer::cTimerRegistration * Lugre::cTimer::RegisterTimeoutListener ( cListener pListener,
const size_t  iTimeOut,
void *  userdata = 0 
)

listener will be notified ONCE in about iTimeOut milliseconds (1000=1sec) after this call, but not during this frame

Definition at line 111 of file lugre_timer.cpp.

References miLastFrameTime, mlTimeouts, and PROFILE.

cTimer::cTimerRegistration * Lugre::cTimer::RegisterIntervalListener ( cListener pListener,
const size_t  iInterval,
void *  userdata = 0 
)

Definition at line 117 of file lugre_timer.cpp.

References miLastFrameTime, mlIntervals, and PROFILE.

cTimer::cTimerRegistration * Lugre::cTimer::RegisterFrameIntervalListener ( cListener pListener,
const size_t  iFrameIntervalExp,
void *  userdata = 0 
)

RegisterFrameIntervalListener takes an EXPONENT, i.e. passing 3 as iFrameIntervalExp will result in getting called every 2^3 = 1<<3 = 8 frames iFrameInterval = 2^iFrameIntervalExp

Definition at line 125 of file lugre_timer.cpp.

References assert, kMaxFrameIntervalExp, miLastFrameTime, mlFrameIntervals, and PROFILE.

Referenced by Lugre::cRadar::cRadar(), and Lugre::cRadialGrid::cRadialGrid().

bool Lugre::cTimer::IsCurFrameInInterval ( const size_t  iInterval  )  [inline]

Definition at line 91 of file lugre_timer.h.

References IsFrameInInterval(), and miCurFrameNum.

Referenced by StartFrame().

static size_t Lugre::cTimer::GetIntervalStart ( const size_t  iInterval  )  [inline, static]

Definition at line 92 of file lugre_timer.h.

Referenced by IsFrameInInterval().

static bool Lugre::cTimer::IsFrameInInterval ( const size_t  iInterval,
const size_t  iFrame 
) [inline, static]

Definition at line 93 of file lugre_timer.h.

References GetIntervalStart().

Referenced by IsCurFrameInInterval().


Member Data Documentation

Definition at line 41 of file lugre_timer.h.

Referenced by StartFrame().

size_t Lugre::cTimer::miLastFrameTime = 0 [static]

size_t Lugre::cTimer::miCurFrameNum = 0 [static]

Definition at line 43 of file lugre_timer.h.

Referenced by IsCurFrameInInterval(), and StartFrame().

float Lugre::cTimer::mfPhysStepTime = 0.0 [static]

Definition at line 44 of file lugre_timer.h.

Referenced by StartFrame().

Definition at line 99 of file lugre_timer.h.

Referenced by RegisterTimeoutListener(), and StartFrame().

Definition at line 100 of file lugre_timer.h.

Referenced by RegisterIntervalListener(), and StartFrame().

Definition at line 101 of file lugre_timer.h.

Referenced by RegisterFrameIntervalListener(), and StartFrame().


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

Generated on Tue May 22 06:00:43 2012 for cpp by  doxygen 1.5.6