Utopia 2
Framework for studying models of complex & adaptive systems.
|
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. | |
void | emit_if_enabled () |
Perform an emission of the data to the terminal, if the flag was set. | |
void | check_timer () |
Checks with the timer whether the time to emit has come. | |
bool | emit_enabled () const |
Returns true if the emission is enabled. | |
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. | |
template<typename Time > | |
void | set_time_entries (const Time time, const Time time_max) |
Set time- and progress-related top level entries. | |
Timer & | get_timer () |
Get a shared pointer to the MonitorTimer object. | |
auto | get_emit_interval () |
Return the emit interval. | |
auto | get_emit_counter () |
Return the emit interval. | |
YAML::Node & | get_entries () |
Get the reference to the monitor entries object. | |
Private Types | |
using | Timer = std::shared_ptr< MonitorTimer > |
Type of the timer. | |
Private Attributes | |
Timer | _timer |
The monitor timer. | |
YAML::Node | _entries |
The monitor entries. | |
bool | _emit_enabled |
The flag that determines whether to collect data. | |
std::size_t | _emit_counter |
Counts the number of emit operations. | |
const std::string | _emit_prefix |
A prefix to the emitted string. | |
const std::string | _emit_suffix |
A suffix to the emitted string. | |
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.
|
private |
Type of the timer.
|
inline |
Constructor.
emit_interval | The emit interval that specifies after how much time to emit the monitor data. |
emit_prefix | A prefix to the emitted string, default: "!!map " |
emit_suffix | A suffix to the emitted string, default: "". Note that std::endl is always appended. |
|
inline |
Checks with the timer whether the time to emit has come.
|
inline |
Returns true if the emission is enabled.
|
inline |
Perform an emission of the data to the terminal, if the flag was set.
|
inline |
Return the emit interval.
|
inline |
Return the emit interval.
|
inline |
Get the reference to the monitor entries object.
|
inline |
Get a shared pointer to the MonitorTimer object.
|
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.
Value | The type of the value that should be monitored |
path | The 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. |
key | The key of the new entry. It is suffixed onto the path with the . delimiter in between, becoming the last segment of the path. |
value | The value of the new entry |
|
inline |
Set time- and progress-related top level entries.
Using the given parameters, this method sets the top-level entries 'time' and 'progress'
Time | The data type of the time |
time | The current time |
time_max | The maximum time of the simulation |
|
private |
Counts the number of emit operations.
|
private |
The flag that determines whether to collect data.
|
private |
A prefix to the emitted string.
|
private |
A suffix to the emitted string.
|
private |
The monitor entries.
|
private |
The monitor timer.