Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
UA_CoMP::Timekeeper::Stopwatch< T > Class Template Reference

Provides a stopwatch interface to time: it accumulates time between start/stop pairs. More...

#include <Stopwatch.h>

Collaboration diagram for UA_CoMP::Timekeeper::Stopwatch< T >:
Collaboration graph

Public Types

typedef T TClock
 

Public Member Functions

 Stopwatch (std::string name="stopwatch", bool running=false)
 Constructor initializes stopwatch. More...
 
StopwatchStart ()
 Starts stopwatch if it was stopped. More...
 
StopwatchStop ()
 Stops the stopwatch if it was running. More...
 
StopwatchReset ()
 Resets stopwatch i.e. More...
 
bool IsRunning () const
 Reports whether stopwatch has been started. More...
 
std::string GetName () const
 Return name of this stopwatch. More...
 
T::duration Get () const
 Returns the accumulated value without altering the stopwatch state. More...
 
std::string ToString () const
 Returns string representation of readout. More...
 

Private Attributes

T::duration m_accumulated
 
T::time_point m_last_start
 
std::string m_name
 
bool m_running
 

Detailed Description

template<typename T = std::chrono::system_clock>
class UA_CoMP::Timekeeper::Stopwatch< T >

Provides a stopwatch interface to time: it accumulates time between start/stop pairs.

Definition at line 33 of file Stopwatch.h.

Member Typedef Documentation

template<typename T = std::chrono::system_clock>
typedef T UA_CoMP::Timekeeper::Stopwatch< T >::TClock

Definition at line 36 of file Stopwatch.h.

Constructor & Destructor Documentation

template<typename T = std::chrono::system_clock>
UA_CoMP::Timekeeper::Stopwatch< T >::Stopwatch ( std::string  name = "stopwatch",
bool  running = false 
)
inline

Constructor initializes stopwatch.

Definition at line 39 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::m_last_start, and UA_CoMP::Timekeeper::Stopwatch< T >::m_running.

Member Function Documentation

template<typename T = std::chrono::system_clock>
Stopwatch& UA_CoMP::Timekeeper::Stopwatch< T >::Start ( )
inline

Starts stopwatch if it was stopped.

Definition at line 48 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::m_last_start, and UA_CoMP::Timekeeper::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
Stopwatch& UA_CoMP::Timekeeper::Stopwatch< T >::Stop ( )
inline
template<typename T = std::chrono::system_clock>
Stopwatch& UA_CoMP::Timekeeper::Stopwatch< T >::Reset ( )
inline

Resets stopwatch i.e.

stopwatch is stopped and time accumulator is cleared.

Definition at line 69 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::m_accumulated, and UA_CoMP::Timekeeper::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
bool UA_CoMP::Timekeeper::Stopwatch< T >::IsRunning ( ) const
inline

Reports whether stopwatch has been started.

Definition at line 77 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::m_running.

template<typename T = std::chrono::system_clock>
std::string UA_CoMP::Timekeeper::Stopwatch< T >::GetName ( ) const
inline

Return name of this stopwatch.

Definition at line 80 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::m_name.

template<typename T = std::chrono::system_clock>
T::duration UA_CoMP::Timekeeper::Stopwatch< T >::Get ( ) const
inline

Returns the accumulated value without altering the stopwatch state.

Definition at line 83 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::m_accumulated, UA_CoMP::Timekeeper::Stopwatch< T >::m_last_start, and UA_CoMP::Timekeeper::Stopwatch< T >::m_running.

Referenced by UA_CoMP::Timekeeper::Stopwatch< T >::ToString().

Here is the caller graph for this function:

template<typename T = std::chrono::system_clock>
std::string UA_CoMP::Timekeeper::Stopwatch< T >::ToString ( ) const
inline

Returns string representation of readout.

Definition at line 93 of file Stopwatch.h.

References UA_CoMP::Timekeeper::Stopwatch< T >::Get(), and UA_CoMP::Timekeeper::Utils::ToColonString().

Here is the call graph for this function:

Member Data Documentation

template<typename T = std::chrono::system_clock>
T::duration UA_CoMP::Timekeeper::Stopwatch< T >::m_accumulated
private
template<typename T = std::chrono::system_clock>
T::time_point UA_CoMP::Timekeeper::Stopwatch< T >::m_last_start
private
template<typename T = std::chrono::system_clock>
std::string UA_CoMP::Timekeeper::Stopwatch< T >::m_name
private

Definition at line 116 of file Stopwatch.h.

Referenced by UA_CoMP::Timekeeper::Stopwatch< T >::GetName().


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