HoverRace  2.0
Classes | Public Member Functions | Private Attributes | List of all members
HoverRace::Util::Stopwatch Class Reference

Records lap times. More...

#include <Stopwatch.h>

Classes

struct  Lap
 

Public Member Functions

 Stopwatch (std::shared_ptr< Clock > clock)
 Constructor. More...
 
 Stopwatch (std::shared_ptr< Clock > clock, const Duration &start)
 Constructor. More...
 
template<typename Fn >
void ForEachLap (Fn fn)
 
Duration NextLap (const std::string &name)
 Start a new lap. More...
 

Private Attributes

std::shared_ptr< Clockclock
 
std::vector< Laplaps
 
Duration lastLap
 

Detailed Description

Records lap times.

Author
Michael Imamura

Constructor & Destructor Documentation

HoverRace::Util::Stopwatch::Stopwatch ( std::shared_ptr< Clock clock)

Constructor.

The start time of the first lap is recorded as the current time of the clock.

Parameters
clockThe clock to use for timing.
HoverRace::Util::Stopwatch::Stopwatch ( std::shared_ptr< Clock clock,
const Duration start 
)

Constructor.

Parameters
clockThe clock to use for timing.
startThe timestamp of the start of the first lap.

Member Function Documentation

template<typename Fn >
void HoverRace::Util::Stopwatch::ForEachLap ( Fn  fn)
inline
Duration HoverRace::Util::Stopwatch::NextLap ( const std::string &  name)

Start a new lap.

Parameters
nameThe name of the lap that just ended.
Returns
The elapsed time for the lap that just ended.

Member Data Documentation

std::shared_ptr<Clock> HoverRace::Util::Stopwatch::clock
private
std::vector<Lap> HoverRace::Util::Stopwatch::laps
private
Duration HoverRace::Util::Stopwatch::lastLap
private

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