nrEngine::TimeSource Class Reference
[Clock and Timers]

Interface for time source give clock a current time. More...

Inheritance diagram for nrEngine::TimeSource:

nrEngine::TimeSourceVirtual

Public Member Functions

 TimeSource ()
virtual ~TimeSource ()
virtual float64 getTime ()
virtual float64 getSystemTime ()
virtual void reset (float64 startValue=0.0)
virtual void sync ()
virtual void notifyNextFrame ()

Protected Attributes

timeval _startTime
 Store here time value given by gettimeofday - function.
float64 _currentTime
 Store the current time in seconds, since the source was resetted.
float64 _syncTime
 Here we store the sncying time point. This will help us to sync the source.
float64 _resetTime
 This is the reset value. The value is used to store time of reset point.

Detailed Description

Interface for time source give clock a current time.

TimeSource is an interface for each time emitter. You have to bind any time source to the clock to have possibility to know the current time. You can think on time source as on tick mechanism in every clock.
In our default imlementation of the time source, we use a high performance tick counter provided by the cpu if such one exists. So you will be able to get more precise time results as usual.
Each time source should be able to provide real system time (real does not mean absolute). The provided time has to be computed through system clock or similar techniques without using of high performance tick counters (e.g. rdtsc). We need this to be able to sync nrEngine's Clock-System for the current CPU-Speed. Because today's CPU does support frequency scaling, so we need somewhere to sync the time.

Definition at line 58 of file TimeSource.h.


Constructor & Destructor Documentation

nrEngine::TimeSource::TimeSource (  ) 

Create an instance of the time source object.

Definition at line 27 of file TimeSource.cpp.

References reset().

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

Release used memory

Definition at line 33 of file TimeSource.cpp.


Member Function Documentation

float64 nrEngine::TimeSource::getTime (  )  [virtual]

Get the current time in seconds. Returned time is not the same as system time.

Returns:
current time in seconds

Reimplemented in nrEngine::TimeSourceVirtual.

Definition at line 55 of file TimeSource.cpp.

References _currentTime, _resetTime, _startTime, and _syncTime.

float64 nrEngine::TimeSource::getSystemTime (  )  [virtual]

Get current system time as it is provided through system functions without using of high performance tick counter (like rdtsc).

Definition at line 38 of file TimeSource.cpp.

void nrEngine::TimeSource::reset ( float64  startValue = 0.0  )  [virtual]

Reset the time source, so it can start reading the time from the beginning. You do not have to call this method, clock will do it automaticaly, if it is needed.

Parameters:
startValue This value will be added to the default start value, which is normally 0. So specifying the startValue parameter modifies the time to which the source should reset.

Reimplemented in nrEngine::TimeSourceVirtual.

Definition at line 73 of file TimeSource.cpp.

References _resetTime, and _startTime.

Referenced by sync(), and TimeSource().

void nrEngine::TimeSource::sync (  )  [virtual]

Syncing the time source means we get the current time store it as sync time point caluclate the new start point do all calculations again. This syncing can help us to sync clock for example if the cpu speed changes. If no new calculation about the cpu speed is done and we use rdtsc to compute the current time, so we will get wrong time steps. Syncing should prevent this.
Clock-Engine will decide by itself when to sync, so time source shouldn't do it.

Definition at line 80 of file TimeSource.cpp.

References _currentTime, _syncTime, and reset().

void nrEngine::TimeSource::notifyNextFrame (  )  [virtual]

Call this method to notify the time source, that new frame beginns. This method is usefull if we are using non-time based time sources. So the time source could read time from some file, which is based on frames.

Reimplemented in nrEngine::TimeSourceVirtual.

Definition at line 87 of file TimeSource.cpp.


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