Class for clock. More...
#include <Clock.hpp>
Collaboration diagram for utl::Clock:Public Types | |
| using | TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock> |
Public Member Functions | |
| Clock (const bool startNow=true) | |
| ~Clock ()=default | |
| Clock (const Clock &)=delete | |
| Clock & | operator= (const Clock &)=delete |
| Clock (Clock &&)=delete | |
| Clock & | operator= (Clock &&)=delete |
| void | restart () |
| Restart the clock. | |
| void | pause () |
| Pause the clock. | |
| void | resume () |
| Resume the clock. | |
| float | getDeltaSeconds () const |
| Get the elapsed time in seconds. | |
| template<typename Duration = std::chrono::seconds> | |
| auto | getElapsed () const |
| Get the elapsed time in specified duration. | |
Static Public Member Functions | |
| static TimePoint | now () |
| Get the current time point. | |
Private Types | |
| using | Duration = std::chrono::high_resolution_clock::duration |
Private Attributes | |
| TimePoint | m_start |
| TimePoint | m_pausedTime |
| Duration | m_pausedDuration |
| bool | m_isPaused {false} |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Clock &clock) |
|
private |
| using utl::Clock::TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock> |
|
inlineexplicit |
|
default |
|
delete |
|
delete |
|
inlinenodiscard |
Get the elapsed time in seconds.
Definition at line 82 of file Clock.hpp.
References m_isPaused, m_pausedDuration, m_pausedTime, m_start, and now().
Here is the call graph for this function:
|
inlinenodiscard |
Get the elapsed time in specified duration.
| Duration | Type of duration to return (default: seconds) |
Definition at line 96 of file Clock.hpp.
References m_pausedDuration, m_start, and now().
Here is the call graph for this function:
|
inlinestatic |
Get the current time point.
Definition at line 43 of file Clock.hpp.
Referenced by getDeltaSeconds(), getElapsed(), pause(), restart(), and resume().
Here is the caller graph for this function:
|
inline |
Pause the clock.
Definition at line 57 of file Clock.hpp.
References m_isPaused, m_pausedTime, and now().
Here is the call graph for this function:
|
inline |
Restart the clock.
Definition at line 48 of file Clock.hpp.
References m_isPaused, m_pausedDuration, m_start, and now().
Here is the call graph for this function:
|
inline |
Resume the clock.
Definition at line 69 of file Clock.hpp.
References m_isPaused, m_pausedDuration, m_pausedTime, and now().
Here is the call graph for this function:
|
friend |
|
private |
|
private |
Definition at line 106 of file Clock.hpp.
Referenced by getDeltaSeconds(), getElapsed(), restart(), and resume().
|
private |
Definition at line 105 of file Clock.hpp.
Referenced by getDeltaSeconds(), pause(), and resume().
|
private |
Definition at line 104 of file Clock.hpp.
Referenced by getDeltaSeconds(), getElapsed(), and restart().