Om
1.0.0
A universal framework for multimedia simulation
|
A timer class that behaves like a stopwatch. More...
#include <omTimer.h>
Public Member Functions | |
Timer () | |
Create a new timer and start it's first interval (by calling update()). More... | |
Time | update () |
Update the timer to the current time and store the interval between updates. More... | |
const Time & | getLastInterval () const |
Return the time interval of the last update. More... | |
Time | getElapsedTime () const |
Return the time interval since the last update without updating the timer. More... | |
Bool | getIsPaused () const |
Get whether or not the timer is currently paused. More... | |
void | setIsPaused (Bool newIsPaused) |
Set whether or not the timer is paused with a boolean flag. More... | |
void | pause () |
Pause the timer. More... | |
void | resume () |
Resume the timer if it is currently paused. More... | |
A timer class that behaves like a stopwatch.
This class serves to provide a way for the user to mark times and to measure the intervals between them. This can be used to do application profiling/timing, to provide a frame time interval counter for games, etc. It uses the highest performance timers availible on the system it is compiled under, and therefore should have sub-millisecond accuracy. The timer is also able to be paused, such that it then behaves as if it was stuck in that instance in which it was paused. It can later be resumed and carry on as if it had never been paused, reflecting this in it's attributes accordingly.
|
inline |
Time om::time::Timer::update | ( | ) |
Update the timer to the current time and store the interval between updates.
This method updates the timer, and then returns and stores the time between the last update and this update. If the timer is paused when this function is called, the the method does nothing.
|
inline |
|
inline |
Return the time interval since the last update without updating the timer.
This method gets the time passed since the last call to the update() method in seconds. The method does not reset the timer, and therefore can be used to get a running total of the time since some arbitrary moment (set by calling the update method). If the timer is paused, this method returns the time between the last call to update() and the time when the timer was paused.
|
inline |
Get whether or not the timer is currently paused.
If the timer is paused, then this means that the timer is no longer keeping track of time, and will behave as if it is stuck in the instant that it was paused in until it is unpaused. This can be useful in many situations where one needs to stop timing and later resume timing as if the timer has never been stopped.
void om::time::Timer::setIsPaused | ( | Bool | newIsPaused | ) |
Set whether or not the timer is paused with a boolean flag.
If the timer is paused, then this means that the timer is no longer keeping track of time, and will behave as if it is stuck in the instant that it was paused in until it is unpaused. This can be useful in many situations where one needs to stop timing and later resume timing as if the timer has never been stopped. If this method is called with a parameter that is equal to the return value of getIsPaused(), then it does nothing (the timer's state doesn't need to change).
newIsPaused | - whether or not the timer should be paused. |
|
inline |
Pause the timer.
If the timer is already paused, then this method does nothing (the timer's state doesn't need to change to reflect the function call).
|
inline |
Resume the timer if it is currently paused.
If the timer is not paused, then this method does nothing (the timer's state doesn't need to change to reflect the function call).