Utopia  2
Framework for studying models of complex & adaptive systems.
Public Types | Public Member Functions | Private Attributes | List of all members
Utopia::DataIO::MonitorTimer Class Reference

The MonitorTimer keeps track of the time when to emit monitor data. More...

#include <monitor.hh>

Public Types

using Clock = std::chrono::high_resolution_clock
 Data type for the clock. More...
 
using Time = std::chrono::high_resolution_clock::time_point
 Data type for a time point. More...
 
using DurationType = std::chrono::duration< double >
 Data type for the time unit. More...
 

Public Member Functions

 MonitorTimer (const double emit_interval)
 Constructor. More...
 
bool time_has_come () const
 Check for whether the time to emit has come or not. More...
 
void reset ()
 Reset the timer to the current time. More...
 
template<class DurationT = DurationType>
const DurationT get_time_elapsed () const
 Get the time elapsed since the start of this timer. More...
 
double get_time_elapsed_seconds () const
 Get the time elapsed since start of this timer, converted to seconds. More...
 
const DurationType get_emit_interval () const
 Return the emit interval. More...
 

Private Attributes

const DurationType _emit_interval
 The emit interval. More...
 
const Time _start_time
 The starting time of the timer. More...
 
Time _last_emit
 The time of the last emit. More...
 

Detailed Description

The MonitorTimer keeps track of the time when to emit monitor data.

Member Typedef Documentation

◆ Clock

using Utopia::DataIO::MonitorTimer::Clock = std::chrono::high_resolution_clock

Data type for the clock.

◆ DurationType

using Utopia::DataIO::MonitorTimer::DurationType = std::chrono::duration< double >

Data type for the time unit.

◆ Time

using Utopia::DataIO::MonitorTimer::Time = std::chrono::high_resolution_clock::time_point

Data type for a time point.

Constructor & Destructor Documentation

◆ MonitorTimer()

Utopia::DataIO::MonitorTimer::MonitorTimer ( const double  emit_interval)
inline

Constructor.

Construct a new Monitor Timer object. The _last_emit time is set to the time of construction.

Parameters
emit_intervalThe time interval that defines whether the time has come to emit data. If more time than the _emit_interval has passed the time_has_come function returns true.

Member Function Documentation

◆ get_emit_interval()

const DurationType Utopia::DataIO::MonitorTimer::get_emit_interval ( ) const
inline

Return the emit interval.

◆ get_time_elapsed()

template<class DurationT = DurationType>
const DurationT Utopia::DataIO::MonitorTimer::get_time_elapsed ( ) const
inline

Get the time elapsed since the start of this timer.

◆ get_time_elapsed_seconds()

double Utopia::DataIO::MonitorTimer::get_time_elapsed_seconds ( ) const
inline

Get the time elapsed since start of this timer, converted to seconds.

◆ reset()

void Utopia::DataIO::MonitorTimer::reset ( )
inline

Reset the timer to the current time.

◆ time_has_come()

bool Utopia::DataIO::MonitorTimer::time_has_come ( ) const
inline

Check for whether the time to emit has come or not.

Parameters
resetReset the internal timer to the current time if the _emit_interval has been exceeded.
Returns
true if the internal timer has exceeded the _last_emit time.

Member Data Documentation

◆ _emit_interval

const DurationType Utopia::DataIO::MonitorTimer::_emit_interval
private

The emit interval.

◆ _last_emit

Time Utopia::DataIO::MonitorTimer::_last_emit
private

The time of the last emit.

◆ _start_time

const Time Utopia::DataIO::MonitorTimer::_start_time
private

The starting time of the timer.


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