cae  0.0.0
Cross-API graphics engine
Loading...
Searching...
No Matches
utl::Clock Class Reference

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
 
Clockoperator= (const Clock &)=delete
 
 Clock (Clock &&)=delete
 
Clockoperator= (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)
 

Detailed Description

Class for clock.

Definition at line 19 of file Clock.hpp.

Member Typedef Documentation

◆ Duration

using utl::Clock::Duration = std::chrono::high_resolution_clock::duration
private

Definition at line 102 of file Clock.hpp.

◆ TimePoint

using utl::Clock::TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock>

Definition at line 23 of file Clock.hpp.

Constructor & Destructor Documentation

◆ Clock() [1/3]

utl::Clock::Clock ( const bool startNow = true)
inlineexplicit

Definition at line 25 of file Clock.hpp.

◆ ~Clock()

utl::Clock::~Clock ( )
default

◆ Clock() [2/3]

utl::Clock::Clock ( const Clock & )
delete

◆ Clock() [3/3]

utl::Clock::Clock ( Clock && )
delete

Member Function Documentation

◆ getDeltaSeconds()

float utl::Clock::getDeltaSeconds ( ) const
inlinenodiscard

Get the elapsed time in seconds.

Returns
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:

◆ getElapsed()

template<typename Duration = std::chrono::seconds>
auto utl::Clock::getElapsed ( ) const
inlinenodiscard

Get the elapsed time in specified duration.

Template Parameters
DurationType of duration to return (default: seconds)
Returns
Elapsed time in specified duration

Definition at line 96 of file Clock.hpp.

References m_pausedDuration, m_start, and now().

+ Here is the call graph for this function:

◆ now()

static TimePoint utl::Clock::now ( )
inlinestatic

Get the current time point.

Returns
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:

◆ operator=() [1/2]

Clock & utl::Clock::operator= ( Clock && )
delete

◆ operator=() [2/2]

Clock & utl::Clock::operator= ( const Clock & )
delete

◆ pause()

void utl::Clock::pause ( )
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:

◆ restart()

void utl::Clock::restart ( )
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:

◆ resume()

void utl::Clock::resume ( )
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:

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Clock & clock )
friend

Definition at line 33 of file Clock.hpp.

Member Data Documentation

◆ m_isPaused

bool utl::Clock::m_isPaused {false}
private

Definition at line 107 of file Clock.hpp.

Referenced by getDeltaSeconds(), pause(), restart(), and resume().

◆ m_pausedDuration

Duration utl::Clock::m_pausedDuration
private

Definition at line 106 of file Clock.hpp.

Referenced by getDeltaSeconds(), getElapsed(), restart(), and resume().

◆ m_pausedTime

TimePoint utl::Clock::m_pausedTime
private

Definition at line 105 of file Clock.hpp.

Referenced by getDeltaSeconds(), pause(), and resume().

◆ m_start

TimePoint utl::Clock::m_start
private

Definition at line 104 of file Clock.hpp.

Referenced by getDeltaSeconds(), getElapsed(), and restart().


The documentation for this class was generated from the following file: