SPH
Public Member Functions | List of all members
Statistics Class Reference

Object holding various statistics about current run. More...

#include <Statistics.h>

Public Member Functions

 Statistics ()=default
 
 Statistics (const Statistics &other)
 
Statisticsoperator= (const Statistics &other)
 
bool has (const StatisticsId idx) const
 Checks if the object contains a statistic with given ID. More...
 
template<typename TValue >
Statisticsset (const StatisticsId idx, TValue &&value)
 Sets new values of a statistic. More...
 
void increment (const StatisticsId idx, const Size amount)
 Increments an integer statistic by given amount. More...
 
void accumulate (const StatisticsId idx, const Float value)
 Accumulate a value into means of given idx. More...
 
template<typename TValue >
TValue get (const StatisticsId idx) const
 Returns value of a statistic. More...
 
template<typename TValue >
TValue getOr (const StatisticsId idx, const TValue &other) const
 Returns value of a statistic, or a given value if the statistic is not stored. More...
 

Detailed Description

Object holding various statistics about current run.

Statistics are stored as key-value pairs, the key being StatisticsId enum defined below. Values are set or accumulated by each component of the running problem (timestepping, solver, ...).

Definition at line 22 of file Statistics.h.

Constructor & Destructor Documentation

◆ Statistics() [1/2]

Statistics::Statistics ( )
default

◆ Statistics() [2/2]

Statistics::Statistics ( const Statistics other)
inline

Definition at line 33 of file Statistics.h.

Member Function Documentation

◆ accumulate()

void Statistics::accumulate ( const StatisticsId  idx,
const Float  value 
)
inline

Accumulate a value into means of given idx.

Value does not have to be stored. If there is no value of given idx, it is created with default constructor prior to accumulating.

Definition at line 73 of file Statistics.h.

◆ get()

template<typename TValue >
TValue Statistics::get ( const StatisticsId  idx) const
inline

Returns value of a statistic.

The value must be stored in the object and must have type TValue, checked by assert.

Definition at line 88 of file Statistics.h.

◆ getOr()

template<typename TValue >
TValue Statistics::getOr ( const StatisticsId  idx,
const TValue &  other 
) const
inline

Returns value of a statistic, or a given value if the statistic is not stored.

Definition at line 98 of file Statistics.h.

◆ has()

bool Statistics::has ( const StatisticsId  idx) const
inline

Checks if the object contains a statistic with given ID.

By default, the object is empty, it contains no data.

Definition at line 44 of file Statistics.h.

◆ increment()

void Statistics::increment ( const StatisticsId  idx,
const Size  amount 
)
inline

Increments an integer statistic by given amount.

Syntatic suggar, equivalent to set(idx, get<int>(idx) + amount).

Definition at line 61 of file Statistics.h.

◆ operator=()

Statistics& Statistics::operator= ( const Statistics other)
inline

Definition at line 36 of file Statistics.h.

◆ set()

template<typename TValue >
Statistics& Statistics::set ( const StatisticsId  idx,
TValue &&  value 
)
inline

Sets new values of a statistic.

This overrides any previously stored value.

Definition at line 52 of file Statistics.h.


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