DiSMEC++
dismec::stats::TagContainer Class Reference

A tag container combines a name with a shared pointer, which points to the tag value. More...

#include <stats_base.h>

Public Member Functions

const std::string & get_name () const
 returns the name of the associated tag More...
 
int get_value () const
 Returns the current value of the tag. Requires the container to not be empty. More...
 
bool is_empty () const
 
void set_value (int value)
 Updates the value of the tag. Requires the container to not be empty. More...
 

Static Public Member Functions

static TagContainer create_empty_container (std::string name)
 
static TagContainer create_full_container (std::string name)
 

Private Member Functions

 TagContainer (std::string name, std::shared_ptr< int > val)
 

Private Attributes

std::string m_Name
 
std::shared_ptr< int > m_Value
 

Detailed Description

A tag container combines a name with a shared pointer, which points to the tag value.

This is a lightweight wrapper around a shared pointer, which is used to manage tags. It can be in an empty and a full state. In the empty state, it has only a name, but not associated value (i.e. m_Value is nullptr), and in the full state it has both. Because updating and reading the value are expected to happen in performance-critical parts of the code, there is no check for empty state in release mode.

Any statistics the needs a tag should create empty tags with the corresponding name during its creation phase, and then fill in the full tag from the given StatisticsCollection during the setup() call.

For now, only integer values are accepted as tag value.

Definition at line 30 of file stats_base.h.

Constructor & Destructor Documentation

◆ TagContainer()

dismec::stats::TagContainer::TagContainer ( std::string  name,
std::shared_ptr< int >  val 
)
inlineexplicitprivate

Definition at line 58 of file stats_base.h.

Referenced by create_empty_container(), and create_full_container().

Member Function Documentation

◆ create_empty_container()

static TagContainer dismec::stats::TagContainer::create_empty_container ( std::string  name)
inlinestatic

Definition at line 50 of file stats_base.h.

References TagContainer().

◆ create_full_container()

static TagContainer dismec::stats::TagContainer::create_full_container ( std::string  name)
inlinestatic

Definition at line 53 of file stats_base.h.

References TagContainer().

Referenced by dismec::stats::StatisticsCollection::declare_tag().

◆ get_name()

const std::string& dismec::stats::TagContainer::get_name ( ) const
inline

returns the name of the associated tag

Definition at line 33 of file stats_base.h.

References m_Name.

Referenced by dismec::stats::TaggedStat::clone(), dismec::stats::TaggedStat::setup(), and TEST_CASE().

◆ get_value()

int dismec::stats::TagContainer::get_value ( ) const
inline

Returns the current value of the tag. Requires the container to not be empty.

Definition at line 36 of file stats_base.h.

References is_empty(), and m_Value.

Referenced by dismec::stats::TaggedStat::record_real(), and TEST_CASE().

◆ is_empty()

bool dismec::stats::TagContainer::is_empty ( ) const
inline

Definition at line 42 of file stats_base.h.

References m_Value.

Referenced by get_value(), and set_value().

◆ set_value()

void dismec::stats::TagContainer::set_value ( int  value)
inline

Updates the value of the tag. Requires the container to not be empty.

Definition at line 45 of file stats_base.h.

References is_empty(), and m_Value.

Member Data Documentation

◆ m_Name

std::string dismec::stats::TagContainer::m_Name
private

Definition at line 60 of file stats_base.h.

Referenced by get_name().

◆ m_Value

std::shared_ptr<int> dismec::stats::TagContainer::m_Value
private

Definition at line 61 of file stats_base.h.

Referenced by get_value(), is_empty(), and set_value().


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