SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::lib::Clock Class Reference

A class that can be used to measure time like a stopwatch. More...

#include <Clock.h>

Public Member Functions

 Clock ()
 Instantiates a new clock and starts it.
 
 Clock (const Clock &other)=default
 
 Clock (Clock &&other) noexcept=default
 
Clockoperator= (const Clock &other)=default
 
Clockoperator= (Clock &&other) noexcept=default
 
template<typename T >
requires IsDuration<T>
float elapsedTime () const
 Gets the elapsed time since the clock start.
 
void restart ()
 Restarts the clock.
 
template<typename T >
requires IsDuration<T>
float restart ()
 Restarts the clock and gets the elapsed time.
 

Detailed Description

A class that can be used to measure time like a stopwatch.

Member Function Documentation

◆ elapsedTime()

template<typename T >
requires IsDuration<T>
float spark::lib::Clock::elapsedTime ( ) const
nodiscard

Gets the elapsed time since the clock start.

Template Parameters
TThe unit of the returned time
Returns
The time since the clock has started for the specified unit

◆ restart()

template<typename T >
requires IsDuration<T>
float spark::lib::Clock::restart ( )
nodiscard

Restarts the clock and gets the elapsed time.

Template Parameters
TThe unit of the returned time
Returns
The time since the clock has started for the specified unit