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

The MonitorManager manages the monitor entries and MonitorTimer. More...

#include <monitor.hh>

Public Member Functions

 MonitorManager (const double emit_interval, const std::string emit_prefix="!!map ", const std::string emit_suffix="")
 Constructor. More...
 
void emit_if_enabled ()
 Perform an emission of the data to the terminal, if the flag was set. More...
 
void check_timer ()
 Checks with the timer whether the time to emit has come. More...
 
bool emit_enabled () const
 Returns true if the emission is enabled. More...
 
template<typename Value >
void set_entry (const std::string &path, const std::string &key, const Value value)
 Set an entry in the tree of monitor entries. More...
 
template<typename Time >
void set_time_entries (const Time time, const Time time_max)
 Set time- and progress-related top level entries. More...
 
Timerget_timer ()
 Get a shared pointer to the MonitorTimer object. More...
 
auto get_emit_interval ()
 Return the emit interval. More...
 
auto get_emit_counter ()
 Return the emit interval. More...
 
YAML::Node & get_entries ()
 Get the reference to the monitor entries object. More...
 

Private Types

using Timer = std::shared_ptr< MonitorTimer >
 Type of the timer. More...
 

Private Attributes

Timer _timer
 The monitor timer. More...
 
YAML::Node _entries
 The monitor entries. More...
 
bool _emit_enabled
 The flag that determines whether to collect data. More...
 
std::size_t _emit_counter
 Counts the number of emit operations. More...
 
const std::string _emit_prefix
 A prefix to the emitted string. More...
 
const std::string _emit_suffix
 A suffix to the emitted string. More...
 

Detailed Description

The MonitorManager manages the monitor entries and MonitorTimer.

The manager performs an emission of the stored monitor data if the monitor timer asserts that enough time has passed since the last emit.

Member Typedef Documentation

◆ Timer

using Utopia::DataIO::MonitorManager::Timer = std::shared_ptr< MonitorTimer >
private

Type of the timer.

Constructor & Destructor Documentation

◆ MonitorManager()

Utopia::DataIO::MonitorManager::MonitorManager ( const double  emit_interval,
const std::string  emit_prefix = "!!map ",
const std::string  emit_suffix = "" 
)
inline

Constructor.

Parameters
emit_intervalThe emit interval that specifies after how much time to emit the monitor data.
emit_prefixA prefix to the emitted string, default: "!!map "
emit_suffixA suffix to the emitted string, default: "". Note that std::endl is always appended.

Member Function Documentation

◆ check_timer()

void Utopia::DataIO::MonitorManager::check_timer ( )
inline

Checks with the timer whether the time to emit has come.

◆ emit_enabled()

bool Utopia::DataIO::MonitorManager::emit_enabled ( ) const
inline

Returns true if the emission is enabled.

◆ emit_if_enabled()

void Utopia::DataIO::MonitorManager::emit_if_enabled ( )
inline

Perform an emission of the data to the terminal, if the flag was set.

◆ get_emit_counter()

auto Utopia::DataIO::MonitorManager::get_emit_counter ( )
inline

Return the emit interval.

◆ get_emit_interval()

auto Utopia::DataIO::MonitorManager::get_emit_interval ( )
inline

Return the emit interval.

◆ get_entries()

YAML::Node& Utopia::DataIO::MonitorManager::get_entries ( )
inline

Get the reference to the monitor entries object.

◆ get_timer()

Timer& Utopia::DataIO::MonitorManager::get_timer ( )
inline

Get a shared pointer to the MonitorTimer object.

◆ set_entry()

template<typename Value >
void Utopia::DataIO::MonitorManager::set_entry ( const std::string &  path,
const std::string &  key,
const Value  value 
)
inline

Set an entry in the tree of monitor entries.

Sets an element at <path>.<key> to value, creating intermediate nodes within the monitor entries tree.

Template Parameters
ValueThe type of the value that should be monitored
Parameters
pathThe path at which to add the key. This can be used to traverse the entries tree. To separate the path segments, the . character is used.
keyThe key of the new entry. It is suffixed onto the path with the . delimiter in between, becoming the last segment of the path.
valueThe value of the new entry

◆ set_time_entries()

template<typename Time >
void Utopia::DataIO::MonitorManager::set_time_entries ( const Time  time,
const Time  time_max 
)
inline

Set time- and progress-related top level entries.

Using the given parameters, this method sets the top-level entries 'time' and 'progress'

Template Parameters
TimeThe data type of the time
Parameters
timeThe current time
time_maxThe maximum time of the simulation

Member Data Documentation

◆ _emit_counter

std::size_t Utopia::DataIO::MonitorManager::_emit_counter
private

Counts the number of emit operations.

◆ _emit_enabled

bool Utopia::DataIO::MonitorManager::_emit_enabled
private

The flag that determines whether to collect data.

◆ _emit_prefix

const std::string Utopia::DataIO::MonitorManager::_emit_prefix
private

A prefix to the emitted string.

◆ _emit_suffix

const std::string Utopia::DataIO::MonitorManager::_emit_suffix
private

A suffix to the emitted string.

◆ _entries

YAML::Node Utopia::DataIO::MonitorManager::_entries
private

The monitor entries.

◆ _timer

Timer Utopia::DataIO::MonitorManager::_timer
private

The monitor timer.


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