Inheritance diagram for nrEngine::TimeSource:
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. |
Definition at line 58 of file TimeSource.h.
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.
float64 nrEngine::TimeSource::getTime | ( | ) | [virtual] |
Get the current time in seconds. Returned time is not the same as system time.
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.
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.