nrEngine::Timer Class Reference
[Clock and Timers]

Timers are used to retrieve time. You can hav emore than one timer in your app. More...

Inheritance diagram for nrEngine::Timer:

nrEngine::ITimeObserver

Public Member Functions

 Timer (Clock &clock)
virtual ~Timer ()
float64 getTime () const
float32 getFrameInterval () const
float32 getRealFrameInterval () const
bool isPaused () const
float32 getScale () const
void setPause (bool bOn)
void setScale (float32 fScale)
virtual void notifyTimeObserver ()
void setFixFrameRate (bool setFixRate, float32 fixFrameRate=60.0f)
NR_FORCEINLINE void resetObserver (float64 resetToTime=0.0f)

Detailed Description

Timers are used to retrieve time. You can hav emore than one timer in your app.

Timer is an standard timer shipped with the engine. You can create your own timers because they are specialized for your application. This timer can only ticks and provide user with information he/she need. Also this timer supports scaling and pausing, so you are able to use at lesser speed or hold on parts of your game using this timer.

Note:
Because each timer is created from the clock, so the timer lifespan is the same as from the clock. So if clock is destroyed, timer will also be killed. You also can not destroy the timer object, only clock can do this.

Definition at line 42 of file Timer.h.


Constructor & Destructor Documentation

nrEngine::Timer::Timer ( Clock clock  ) 

Define default values and set clock for using with this timer. This timer will automaticly be added to the clock as observer.

Definition at line 22 of file Timer.cpp.

References setFixFrameRate(), setPause(), and setScale().

nrEngine::Timer::~Timer (  )  [virtual]

Release used memory and remove this timer from observer list of the clock.

Definition at line 36 of file Timer.cpp.


Member Function Documentation

float64 nrEngine::Timer::getTime (  )  const

Returns current time since this timer is started

Definition at line 60 of file Timer.h.

float32 nrEngine::Timer::getFrameInterval (  )  const

Returns the time interval between two frames Frame interval depends on the scale value you set for this timer. So it can be different for different timers

Definition at line 67 of file Timer.h.

float32 nrEngine::Timer::getRealFrameInterval (  )  const

Returns real frame interval based on Clock::getRealFrameInterval();

Definition at line 62 of file Timer.cpp.

References nrEngine::Clock::getRealFrameInterval().

bool nrEngine::Timer::isPaused (  )  const

Returns true if this timer is currently sleeping/paused

Definition at line 77 of file Timer.h.

float32 nrEngine::Timer::getScale (  )  const

Returns the time scale value of this timer. Each timer can have each own opinion how much time is passed. This is done by setting the scale value of the timer. This scale shows how much faster/slower this timer runs

Definition at line 84 of file Timer.h.

void nrEngine::Timer::setPause ( bool  bOn  ) 

This will hold on this timer so time stops

Parameters:
bOn if true timer stops, otherwise it runs

Definition at line 90 of file Timer.h.

Referenced by Timer().

void nrEngine::Timer::setScale ( float32  fScale  ) 

Set time scale value for this timer. With the help of this value you have the possibility to run your local time at different speed

Definition at line 96 of file Timer.h.

Referenced by Timer().

void nrEngine::Timer::notifyTimeObserver (  )  [virtual]

This function will be always called by clock. Here the main update of the timer is done.

Implements nrEngine::ITimeObserver.

Definition at line 41 of file Timer.cpp.

References nrEngine::Clock::getFrameInterval().

void nrEngine::Timer::setFixFrameRate ( bool  setFixRate,
float32  fixFrameRate = 60.0f 
)

If you set this to true so fix frame rate will be used. This helps us to run our application on console or do internal calculations based on fix frame rate like Doom3 does.

Parameters:
setFixRate if true fix frame rate will be used.
fixFrameRate frame rate to be used

Definition at line 55 of file Timer.cpp.

Referenced by Timer().

NR_FORCEINLINE void nrEngine::Timer::resetObserver ( float64  resetToTime = 0.0f  )  [virtual]

Reset the timer, so it start count the time from the value you define

Implements nrEngine::ITimeObserver.

Definition at line 138 of file Timer.h.

References nrEngine::ITimeObserver::getObserverID(), and nrEngine::Log::LOG_ENGINE.


The documentation for this class was generated from the following files:
Generated on Wed Sep 12 23:19:43 2007 for nrEngine by  doxygen 1.5.1