Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
hgps::RuntimeMetric Class Reference

Defines the Simulation run-time metrics container data type. More...

#include <runtime_metric.h>

Public Types

using IteratorType = std::unordered_map< std::string, double >::iterator
 Metric iterator. More...
 
using ConstIteratorType = std::unordered_map< std::string, double >::const_iterator
 Read-only metric iterator. More...
 

Public Member Functions

std::size_t size () const noexcept
 Gets the number of metrics in the container. More...
 
double & operator[] (const std::string metric_key)
 Gets a reference to a metric value by identifier, no bounds checking. More...
 
double & at (const std::string metric_key)
 Gets a reference to a metric value by identifier with bounds checking. More...
 
const double & at (const std::string metric_key) const
 Gets a read-only reference to a metric value by identifier with bounds checking. More...
 
bool contains (const std::string metric_key) const noexcept
 Checks if the container contains a metric with specific identifier. More...
 
bool emplace (const std::string metric_key, const double value)
 Inserts a new metric into the container constructed in-place with arguments. More...
 
bool erase (const std::string metric_key)
 Removes a specified metric from the container. More...
 
void clear () noexcept
 Erases all metrics from the container. More...
 
void reset () noexcept
 Resets the values of all metrics in the container to zero. More...
 
bool empty () const noexcept
 Checks if the container has no metrics. More...
 
IteratorType begin () noexcept
 Gets an iterator to the beginning of the metrics. More...
 
IteratorType end () noexcept
 Gets an iterator to the element following the last metric. More...
 
ConstIteratorType begin () const noexcept
 Gets a read-only iterator to the beginning of the metrics. More...
 
ConstIteratorType end () const noexcept
 Gets a read-only iterator to the element following the last metric. More...
 
ConstIteratorType cbegin () const noexcept
 Gets a read-only iterator to the beginning of the metrics. More...
 
ConstIteratorType cend () const noexcept
 Gets a read-only iterator to the element following the last metric. More...
 

Detailed Description

Defines the Simulation run-time metrics container data type.

Dynamic runtime metrics can be consistent collected throughout the simulation algorithm, these metrics are included in the simulation results for analysis.

Member Typedef Documentation

◆ ConstIteratorType

using hgps::RuntimeMetric::ConstIteratorType = std::unordered_map<std::string, double>::const_iterator

Read-only metric iterator.

◆ IteratorType

using hgps::RuntimeMetric::IteratorType = std::unordered_map<std::string, double>::iterator

Metric iterator.

Member Function Documentation

◆ at() [1/2]

double & hgps::RuntimeMetric::at ( const std::string  metric_key)

Gets a reference to a metric value by identifier with bounds checking.

Parameters
metric_keyMetric identifier.
Returns
Reference to metric value.
Exceptions
std::out_of_rangeif the container does not have a metric with the specified identifier.

◆ at() [2/2]

const double & hgps::RuntimeMetric::at ( const std::string  metric_key) const

Gets a read-only reference to a metric value by identifier with bounds checking.

Parameters
metric_keyMetric identifier.
Returns
Reference to metric value.
Exceptions
std::out_of_rangeif the container does not have a metric with the specified identifier.

◆ begin() [1/2]

ConstIteratorType hgps::RuntimeMetric::begin ( ) const
inlinenoexcept

Gets a read-only iterator to the beginning of the metrics.

Returns
Iterator to the first metric

◆ begin() [2/2]

IteratorType hgps::RuntimeMetric::begin ( )
inlinenoexcept

Gets an iterator to the beginning of the metrics.

Returns
Iterator to the first metric

◆ cbegin()

ConstIteratorType hgps::RuntimeMetric::cbegin ( ) const
inlinenoexcept

Gets a read-only iterator to the beginning of the metrics.

Returns
Iterator to the first metric

◆ cend()

ConstIteratorType hgps::RuntimeMetric::cend ( ) const
inlinenoexcept

Gets a read-only iterator to the element following the last metric.

Returns
Iterator to the element following the last metric.

◆ clear()

void hgps::RuntimeMetric::clear ( )
noexcept

Erases all metrics from the container.

Here is the caller graph for this function:

◆ contains()

bool hgps::RuntimeMetric::contains ( const std::string  metric_key) const
noexcept

Checks if the container contains a metric with specific identifier.

Parameters
metric_keyMetric identifier.
Returns
true if there is such a metric; otherwise, false.

◆ emplace()

bool hgps::RuntimeMetric::emplace ( const std::string  metric_key,
const double  value 
)

Inserts a new metric into the container constructed in-place with arguments.

Parameters
metric_keyMetric identifier.
valueMetric value.
Returns
true if insertion happened; otherwise, false.

◆ empty()

bool hgps::RuntimeMetric::empty ( ) const
noexcept

Checks if the container has no metrics.

Returns
true if the container is empty; otherwise, false.

◆ end() [1/2]

ConstIteratorType hgps::RuntimeMetric::end ( ) const
inlinenoexcept

Gets a read-only iterator to the element following the last metric.

Returns
Iterator to the element following the last metric.

◆ end() [2/2]

IteratorType hgps::RuntimeMetric::end ( )
inlinenoexcept

Gets an iterator to the element following the last metric.

Returns
Iterator to the element following the last metric.

◆ erase()

bool hgps::RuntimeMetric::erase ( const std::string  metric_key)

Removes a specified metric from the container.

Parameters
metric_keyMetric identifier.
Returns
true if deletion happened; otherwise, false.

◆ operator[]()

double & hgps::RuntimeMetric::operator[] ( const std::string  metric_key)

Gets a reference to a metric value by identifier, no bounds checking.

Parameters
metric_keyMetric identifier.
Returns
Reference to metric value.

◆ reset()

void hgps::RuntimeMetric::reset ( )
noexcept

Resets the values of all metrics in the container to zero.

Here is the caller graph for this function:

◆ size()

std::size_t hgps::RuntimeMetric::size ( ) const
noexcept

Gets the number of metrics in the container.

Returns
The number of metrics.

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