SPH
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
StoppableTimer Class Reference

Simple extension of Timer allowing to pause and continue timer. More...

#include <Timer.h>

Inheritance diagram for StoppableTimer:
Timer

Public Member Functions

void stop ()
 Stops the timer. Function getElapsed() will report the same value from now on. More...
 
void resume ()
 Resumes stopped timer. More...
 
int64_t elapsed (const TimerUnit unit) const
 Returns elapsed time in timer units. Does not reset the timer. More...
 
- Public Member Functions inherited from Timer
 Timer (const int64_t interval=0, const Flags< TimerFlags > flags=EMPTY_FLAGS)
 Creates timer with given expiration duration. More...
 
void restart ()
 Reset elapsed duration to zero. More...
 
int64_t elapsed (const TimerUnit unit) const
 Returns elapsed time in timer units. Does not reset the timer. More...
 
bool isExpired () const
 Checks if the interval has already passed. More...
 
bool isPeriodic () const
 

Protected Member Functions

auto elapsedImpl () const
 

Protected Attributes

TimePoint stopped
 
bool isStopped = false
 
- Protected Attributes inherited from Timer
TimePoint started
 
int64_t interval
 
Flags< TimerFlagsflags
 

Additional Inherited Members

- Protected Types inherited from Timer
using Clock = std::chrono::system_clock
 
using TimePoint = std::chrono::time_point< Clock >
 

Detailed Description

Simple extension of Timer allowing to pause and continue timer.

Definition at line 72 of file Timer.h.

Member Function Documentation

◆ elapsed()

int64_t StoppableTimer::elapsed ( const TimerUnit  unit) const

Returns elapsed time in timer units. Does not reset the timer.

Definition at line 85 of file Timer.cpp.

◆ elapsedImpl()

auto StoppableTimer::elapsedImpl ( ) const
inlineprotected

Definition at line 77 of file Timer.h.

◆ resume()

void StoppableTimer::resume ( )

Resumes stopped timer.

Definition at line 77 of file Timer.cpp.

◆ stop()

void StoppableTimer::stop ( )

Stops the timer. Function getElapsed() will report the same value from now on.

Definition at line 70 of file Timer.cpp.

Member Data Documentation

◆ isStopped

bool StoppableTimer::isStopped = false
protected

Definition at line 75 of file Timer.h.

◆ stopped

TimePoint StoppableTimer::stopped
protected

Definition at line 74 of file Timer.h.


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