r-type  0.0.0
R-Type main
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 ()
 
void pause ()
 
void resume ()
 
float getDeltaSeconds () const
 
template<typename Duration = std::chrono::seconds>
auto getElapsed () const
 

Static Public Member Functions

static TimePoint now ()
 

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 20 of file Clock.hpp.

Member Typedef Documentation

◆ Duration

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

Definition at line 78 of file Clock.hpp.

◆ TimePoint

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

Definition at line 24 of file Clock.hpp.

Constructor & Destructor Documentation

◆ Clock() [1/3]

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

Definition at line 26 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

Definition at line 63 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

Definition at line 72 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

Definition at line 40 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

Definition at line 47 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

Definition at line 41 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

Definition at line 55 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 34 of file Clock.hpp.

Member Data Documentation

◆ m_isPaused

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

Definition at line 83 of file Clock.hpp.

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

◆ m_pausedDuration

Duration utl::Clock::m_pausedDuration
private

Definition at line 82 of file Clock.hpp.

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

◆ m_pausedTime

TimePoint utl::Clock::m_pausedTime
private

Definition at line 81 of file Clock.hpp.

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

◆ m_start

TimePoint utl::Clock::m_start
private

Definition at line 80 of file Clock.hpp.

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


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