Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
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.
 
 Monitor (const std::string &name, const Monitor &parent_mtr)
 Construct a monitor object within a hierarchy.
 
template<typename Func >
void set_by_func (const std::string key, Func &&f)
 Provide a new entry to the monitor manager.
 
template<typename Value >
void set_by_value (const std::string key, Value const &v)
 Provide a new entry to the monitor manager.
 
template<typename Arg >
void set_entry (const std::string key, Arg arg)
 Provide a new entry to the monitor manager.
 
std::shared_ptr< MonitorManagerget_monitor_manager () const
 Get a shared pointer to the MonitorManager.
 
std::string get_name () const
 Get the name of the monitor.
 

Private Attributes

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

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
341 :
342 _name(""),
const std::string _name
The name of the monitor.
Definition monitor.hh:328
std::shared_ptr< MonitorManager > _mtr_mgr
The monitor manager.
Definition monitor.hh:331
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213

◆ 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
355 :
356 _name(parent_mtr.get_name() + "." + name),
357 _mtr_mgr(parent_mtr.get_monitor_manager()){};

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.

423 {
424 return _mtr_mgr;
425 }

◆ get_name()

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

Get the name of the monitor.

430 {
431 return _name;
432 }

◆ 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
370 {
371 _mtr_mgr->set_entry(_name, key, f());
372 }

◆ 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
386 {
387 _mtr_mgr->set_entry(_name, key, v);
388 }

◆ 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
409 {
410 if constexpr (is_callable< Arg >::value)
411 {
413 }
414 else
415 {
417 }
418 }
void set_by_value(const std::string key, Value const &v)
Provide a new entry to the monitor manager.
Definition monitor.hh:385
void set_by_func(const std::string key, Func &&f)
Provide a new entry to the monitor manager.
Definition monitor.hh:369
static constexpr bool value
Definition monitor.hh:58

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: