LibreOffice Module canvas (master) 1
|
Calculate elapsed time. More...
#include <elapsedtime.hxx>
Public Member Functions | |
ElapsedTime () | |
Create a new ElapsedTime object. More... | |
ElapsedTime (std::shared_ptr< ElapsedTime > xTimeBase) | |
Creates a new ElapsedTime object based on another timer. More... | |
void | reset () |
Reset the time. More... | |
double | getElapsedTime () const |
Query the elapsed time. More... | |
void | pauseTimer () |
Pauses the running timer. More... | |
void | continueTimer () |
Continues the paused timer. More... | |
void | adjustTimer (double fOffset) |
Adjusts the timer, hold and pause times. More... | |
void | holdTimer () |
Holds the current time. More... | |
void | releaseTimer () |
Releases a held timer. More... | |
Private Member Functions | |
double | getCurrentTime () const |
double | getElapsedTimeImpl () const |
Static Private Member Functions | |
static double | getSystemTime () |
Private Attributes | |
const std::shared_ptr< ElapsedTime > | m_pTimeBase |
double | m_fLastQueriedTime |
To validate adjustTimer() calls with bLimitToLastQueriedTime=true. More... | |
double | m_fStartTime |
Start time, from which the difference to the time base is returned. More... | |
double | m_fFrozenTime |
Instant, when last pause or hold started, relative to m_fStartTime. More... | |
bool | m_bInPauseMode |
True, when in pause mode. More... | |
bool | m_bInHoldMode |
True, when in hold mode. More... | |
Calculate elapsed time.
This class provides several time-measurement and -management functions. In its simplest use-case, it measures the time from its creation.
Definition at line 34 of file elapsedtime.hxx.
canvas::tools::ElapsedTime::ElapsedTime | ( | ) |
Create a new ElapsedTime object.
The moment of construction starts the time measurement. That means, a subsequent getElapsedTime() call will return the time difference between object creation and getElapsedTime() call.
Definition at line 34 of file elapsedtime.cxx.
canvas::tools::ElapsedTime::ElapsedTime | ( | std::shared_ptr< ElapsedTime > | xTimeBase | ) |
Creates a new ElapsedTime object based on another timer.
The moment of construction starts the time measurement. That means, a subsequent getElapsedTime() call will return the time difference between object creation and getElapsedTime() call. All time values are not taken from the system's time base, but from the provided timer.
Definition at line 44 of file elapsedtime.cxx.
void canvas::tools::ElapsedTime::adjustTimer | ( | double | fOffset | ) |
Adjusts the timer, hold and pause times.
This method modifies the time as returned by this object by the specified amount. This affects the time as returned by getElapsedTime(), regardless of the mode (e.g. paused, or on hold).
fOffset | This value will be added to the current time, i.e. the next call to getElapsedTime() (when performed immediately) will be adjusted by fOffset. |
Definition at line 64 of file elapsedtime.cxx.
References m_bInHoldMode, m_bInPauseMode, m_fFrozenTime, and m_fStartTime.
void canvas::tools::ElapsedTime::continueTimer | ( | ) |
Continues the paused timer.
This method re-enables the time flow, that is, time starts running again for clients calling getElapsedTime(). The (subtle) difference to the holdTimer/releaseTimer() methods below is, that there is no perceived time 'jump' between the pauseTimer() call and the continueTimer() call, i.e. the time starts over with the same value it has stopped on pauseTimer().
Definition at line 101 of file elapsedtime.cxx.
References getElapsedTimeImpl(), m_bInPauseMode, m_fFrozenTime, and m_fStartTime.
|
private |
Definition at line 76 of file elapsedtime.cxx.
References getSystemTime(), and m_pTimeBase.
Referenced by getElapsedTimeImpl(), and reset().
double canvas::tools::ElapsedTime::getElapsedTime | ( | ) | const |
Query the elapsed time.
This method returns the elapsed time in seconds between either the construction of this object, or the last reset() call, if any (but see the time modulation methods below, for means to modify the otherwise continuous flow of time).
Definition at line 81 of file elapsedtime.cxx.
References getElapsedTimeImpl(), and m_fLastQueriedTime.
Referenced by vclcanvas::SpriteCanvasHelper::renderFrameCounter().
|
private |
Definition at line 87 of file elapsedtime.cxx.
References getCurrentTime(), m_bInHoldMode, m_bInPauseMode, m_fFrozenTime, and m_fStartTime.
Referenced by continueTimer(), getElapsedTime(), holdTimer(), and pauseTimer().
|
staticprivate |
Definition at line 29 of file elapsedtime.cxx.
Referenced by getCurrentTime().
void canvas::tools::ElapsedTime::holdTimer | ( | ) |
Holds the current time.
This call makes the timer hold the current time (e.g. getElapsedTime() will return the time when holdTimer() was called), while the underlying time is running on. When releaseTimer() is called, the time will 'jump' to the then-current, underlying time. This is equivalent to pressing the "interim time" button on a stop watch, which shows this stopped time, while the clock keeps running internally.
Definition at line 115 of file elapsedtime.cxx.
References getElapsedTimeImpl(), m_bInHoldMode, and m_fFrozenTime.
void canvas::tools::ElapsedTime::pauseTimer | ( | ) |
Pauses the running timer.
This method stops the time, as returned by this object, until continueTimer() is called. During this period, getElapsedTime() will always return the same time value (i.e. the instant when pauseTimer() was called).
Definition at line 95 of file elapsedtime.cxx.
References getElapsedTimeImpl(), m_bInPauseMode, and m_fFrozenTime.
void canvas::tools::ElapsedTime::releaseTimer | ( | ) |
Releases a held timer.
After this call, the timer again returns the running time on getElapsedTime().
Definition at line 123 of file elapsedtime.cxx.
References m_bInHoldMode.
void canvas::tools::ElapsedTime::reset | ( | ) |
Reset the time.
The instance of the reset() call starts the time measurement from scratch. That means, a subsequent getElapsedTime() call will return the time difference between reset() and getElapsedTime() call.
Definition at line 55 of file elapsedtime.cxx.
References getCurrentTime(), m_bInHoldMode, m_bInPauseMode, m_fFrozenTime, m_fLastQueriedTime, and m_fStartTime.
Referenced by vclcanvas::SpriteCanvasHelper::renderFrameCounter().
|
private |
True, when in hold mode.
Definition at line 156 of file elapsedtime.hxx.
Referenced by adjustTimer(), getElapsedTimeImpl(), holdTimer(), releaseTimer(), and reset().
|
private |
True, when in pause mode.
Definition at line 153 of file elapsedtime.hxx.
Referenced by adjustTimer(), continueTimer(), getElapsedTimeImpl(), pauseTimer(), and reset().
|
private |
Instant, when last pause or hold started, relative to m_fStartTime.
Definition at line 150 of file elapsedtime.hxx.
Referenced by adjustTimer(), continueTimer(), getElapsedTimeImpl(), holdTimer(), pauseTimer(), and reset().
|
mutableprivate |
To validate adjustTimer() calls with bLimitToLastQueriedTime=true.
Definition at line 144 of file elapsedtime.hxx.
Referenced by getElapsedTime(), and reset().
|
private |
Start time, from which the difference to the time base is returned.
Definition at line 147 of file elapsedtime.hxx.
Referenced by adjustTimer(), continueTimer(), getElapsedTimeImpl(), and reset().
|
private |
Definition at line 141 of file elapsedtime.hxx.
Referenced by getCurrentTime().