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

The Monitor monitors entries that are emitted if a given time has passed. More...

#include <monitor.hh>

Public Member Functions

 Monitor (std::shared_ptr< MonitorManager > root_mtr_mgr)
 Constructs a root monitor object. More...
 
 Monitor (const std::string &name, const Monitor &parent_mtr)
 Construct a monitor object within a hierarchy. More...
 
template<typename Func >
void set_by_func (const std::string key, Func &&f)
 Provide a new entry to the monitor manager. More...
 
template<typename Value >
void set_by_value (const std::string key, Value const &v)
 Provide a new entry to the monitor manager. More...
 
template<typename Arg >
void set_entry (const std::string key, Arg arg)
 Provide a new entry to the monitor manager. More...
 
std::shared_ptr< MonitorManagerget_monitor_manager () const
 Get a shared pointer to the MonitorManager. More...
 
std::string get_name () const
 Get the name of the monitor. More...
 

Private Attributes

const std::string _name
 The name of the monitor. More...
 
std::shared_ptr< MonitorManager_mtr_mgr
 The monitor manager. More...
 

Detailed Description

The Monitor monitors entries that are emitted if a given time has passed.

Constructor & Destructor Documentation

◆ Monitor() [1/2]

Utopia::DataIO::Monitor::Monitor ( std::shared_ptr< MonitorManager root_mtr_mgr)
inline

Constructs a root monitor object.

A root monitor has no name and writes to the root level of the monitor entries tree.

Parameters
root_mtr_mgrThe monitor manager to associate this monitor with

◆ Monitor() [2/2]

Utopia::DataIO::Monitor::Monitor ( const std::string &  name,
const Monitor parent_mtr 
)
inline

Construct a monitor object within a hierarchy.

Construct a new Monitor object and names it such that it fits into the monitor hierarchy

Parameters
nameThe name of this monitor; to place it into the monitor hierarchy the parent's name is prepended to this given name, separated by the . character.
parent_mtrThe parent monitor

Member Function Documentation

◆ get_monitor_manager()

std::shared_ptr< MonitorManager > Utopia::DataIO::Monitor::get_monitor_manager ( ) const
inline

Get a shared pointer to the MonitorManager.

◆ get_name()

std::string Utopia::DataIO::Monitor::get_name ( ) const
inline

Get the name of the monitor.

◆ set_by_func()

template<typename Func >
void Utopia::DataIO::Monitor::set_by_func ( const std::string  key,
Func &&  f 
)
inline

Provide a new entry to the monitor manager.

Note
An entry is set regardless of whether the emission is enabled.
Template Parameters
FuncThe type of the function (rvalue reference)
Parameters
keyThe key of the new entry
valueThe value of the new entry

◆ set_by_value()

template<typename Value >
void Utopia::DataIO::Monitor::set_by_value ( const std::string  key,
Value const &  v 
)
inline

Provide a new entry to the monitor manager.

Note
An entry is set regardless of whether the emission is enabled.
Template Parameters
ValueThe type of the value (lvalue reference)
Parameters
keyThe key of the new entry
valueThe value of the new entry

◆ set_entry()

template<typename Arg >
void Utopia::DataIO::Monitor::set_entry ( const std::string  key,
Arg  arg 
)
inline

Provide a new entry to the monitor manager.

This function tests whether the argument is callable like a std::function or a lambda excluding the operator(). If so, they are called and the return value is used for setting the entry.

(Without the exclusion of operator(), types such as int or double would also be classified callable.)

Note
An entry is set regardless of whether the emission is enabled!
Template Parameters
ArgThe type of the argument
Parameters
keyThe key of the new entry
argThe argument (value or function) that determines the value of the new entry

Member Data Documentation

◆ _mtr_mgr

std::shared_ptr< MonitorManager > Utopia::DataIO::Monitor::_mtr_mgr
private

The monitor manager.

◆ _name

const std::string Utopia::DataIO::Monitor::_name
private

The name of the monitor.

Used when setting entries via MonitorManager::set_entry


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