|
Terminus
|
The Timer class implements a set of pauseable duration counters (subsequently called timers) and mechanisms to adjust them individually or globally. More...
#include <timer.h>
Public Types | |
| using | TimerID = unsigned int |
| using | TimerMSec = signed int |
Public Member Functions | |
| Timer () | |
| void | pause () |
| toggle global pause state More... | |
| void | pause (bool flag) |
| set global pause state according to flag More... | |
| bool | isPaused () |
| TimerID | allocateTimer () |
| allocate a new timer without naming it More... | |
| TimerID | allocateTimer (std::string name) |
| allocate a new named timer More... | |
| void | releaseTimer (TimerID id) |
| release ressources (id and timestamp) of an unnamed timer More... | |
| void | releaseTimer (std::string name) |
| release ressources (name, id and timestamp) of a named timer More... | |
| bool | isAllocated (TimerID id) |
| bool | isAllocated (std::string name) |
| TimerMSec | get () |
| TimerMSec | get (TimerID id) |
| TimerMSec | get (std::string name) |
| void | adjust (TimerMSec newNow) |
| adjust the reference time to match newNow More... | |
| void | adjust (TimerID id, TimerMSec newNow) |
| adjust the value of an unnamed timer to match newNow More... | |
| void | adjust (std::string name, TimerMSec newNow) |
| adjust the value of a named timer to match newNow More... | |
Protected Member Functions | |
| TimerID | freeTimerID () |
| std::chrono::steady_clock::time_point | localNow () |
| void | startPause () |
| void | endPause () |
Static Protected Member Functions | |
| static TimerMSec | toMSec (std::chrono::steady_clock::duration duration) |
| static std::chrono::steady_clock::duration | fromMSec (TimerMSec duration) |
Protected Attributes | |
| std::chrono::steady_clock | m_clock |
| std::chrono::steady_clock::time_point | m_pauseNow |
| bool | m_isPaused |
| std::chrono::steady_clock::time_point | m_baseTimeStamp |
| std::map< TimerID, std::chrono::steady_clock::time_point > | m_timeStamps |
| std::map< std::string, TimerID > | m_namedTimers |
The Timer class implements a set of pauseable duration counters (subsequently called timers) and mechanisms to adjust them individually or globally.
Timers can be allocated with a name that allows them to be accessed in contexts where their id is not known.
| using terminus::Timer::TimerID = unsigned int |
| using terminus::Timer::TimerMSec = signed int |
| terminus::Timer::Timer | ( | ) |
| void terminus::Timer::adjust | ( | Timer::TimerMSec | newNow | ) |
adjust the reference time to match newNow
| newNow | - time in milliseconds |
this method affects both the time returned by get() and get(id) or get(name) as named and unnamed timers operate relative to the reference time
| void terminus::Timer::adjust | ( | Timer::TimerID | id, |
| Timer::TimerMSec | newNow | ||
| ) |
adjust the value of an unnamed timer to match newNow
| id | |
| newNow | - time in milliseconds |
does nothing for unallocated timer ids
| void terminus::Timer::adjust | ( | std::string | name, |
| Timer::TimerMSec | newNow | ||
| ) |
adjust the value of a named timer to match newNow
| name | |
| newNow | - time in milliseconds |
allocates a new timer, if it is not allocated already
| Timer::TimerID terminus::Timer::allocateTimer | ( | ) |
allocate a new timer without naming it
| Timer::TimerID terminus::Timer::allocateTimer | ( | std::string | name | ) |
allocate a new named timer
| name |
|
protected |
|
protected |
|
staticprotected |
| Timer::TimerMSec terminus::Timer::get | ( | ) |
the reference time is the time passed since instantiation of this timer object
| Timer::TimerMSec terminus::Timer::get | ( | TimerID | id | ) |
| id |
returns 0 msec for unallocated timer ids
| Timer::TimerMSec terminus::Timer::get | ( | std::string | name | ) |
| name |
allocates a new named timer, if it is not allocated already
| bool terminus::Timer::isAllocated | ( | TimerID | id | ) |
| id | of any timer |
The id can belong both to a named or unnamed timer
| bool terminus::Timer::isAllocated | ( | std::string | name | ) |
| name | of a named timer |
| bool terminus::Timer::isPaused | ( | ) |
|
protected |
| void terminus::Timer::pause | ( | ) |
toggle global pause state
| void terminus::Timer::pause | ( | bool | flag | ) |
set global pause state according to flag
| flag |
| void terminus::Timer::releaseTimer | ( | Timer::TimerID | id | ) |
release ressources (id and timestamp) of an unnamed timer
| id |
| void terminus::Timer::releaseTimer | ( | std::string | name | ) |
release ressources (name, id and timestamp) of a named timer
| name |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
1.8.9.1