RAPIDO
Repeatable Analysis Programming for Interpretability, Durability, and Organization
Loading...
Searching...
No Matches
Utilities::Variables Class Reference

#include <utilities.h>

Public Member Functions

 Variables ()
 
virtual ~Variables ()
 
template<typename Type >
void newVar (std::string new_name)
 
template<typename Type >
void newVar (std::string new_name, Type new_reset_value)
 
template<typename Type >
Type getVal (std::string name)
 
template<typename Type >
Type & getRef (std::string name)
 
template<typename Type >
void setVal (std::string name, Type new_value)
 
template<typename Type >
void resetVal (std::string name)
 
void resetVars ()
 

Protected Member Functions

template<typename Type >
Variable< Type > * getVar (std::string name)
 

Protected Attributes

std::map< std::string, Dynamic * > variables
 
std::map< std::string, std::function< void()> > resetters
 

Detailed Description

A group of "dynamic" variables

Constructor & Destructor Documentation

◆ Variables()

Utilities::Variables::Variables ( )

Variables object constructor

Returns
none

◆ ~Variables()

virtual Utilities::Variables::~Variables ( )
virtual

Variables object destructor

Returns
none

Member Function Documentation

◆ getRef()

template<typename Type >
Type & Utilities::Variables::getRef ( std::string name)

Get variable value in map by reference if it exists

Template Parameters
Typetype of variable
Parameters
namename of variable
Returns
none

◆ getVal()

template<typename Type >
Type Utilities::Variables::getVal ( std::string name)

Get variable value in map if it exists

Template Parameters
Typetype of variable
Parameters
namename of variable
Returns
none

◆ getVar()

template<typename Type >
Variable< Type > * Utilities::Variables::getVar ( std::string name)
protected

(PROTECTED) Retrieve variable object from map if it exists

Template Parameters
Typetype of variable
Parameters
namename of variable
Returns
none

◆ newVar() [1/2]

template<typename Type >
void Utilities::Variables::newVar ( std::string new_name)

Add blank variable to map

Template Parameters
Typetype of new variable
Parameters
new_namename of new variable
Returns
none

◆ newVar() [2/2]

template<typename Type >
void Utilities::Variables::newVar ( std::string new_name,
Type new_reset_value )

Add new variable to map with reset value

Template Parameters
Typetype of variable
Parameters
new_namename of variable
new_reset_valuereset value of new variable
Returns
none

◆ resetVal()

template<typename Type >
void Utilities::Variables::resetVal ( std::string name)

Set value of a variable in map to its reset value if it exists

Template Parameters
Typetype of variable
Parameters
namename of variable
Returns
none

◆ resetVars()

void Utilities::Variables::resetVars ( )

Set value of each variable in map to its respective reset value.

Uses a map of "resetters" because Utilities::Variable<Type>::resetValue() cannot be called across an arbitrary number of such objects, due to the fact that the value of Type for each object would need to be supplied. The "resetters" circumvent this issue by capturing the function call in a lambda function for later use.

Returns
none

◆ setVal()

template<typename Type >
void Utilities::Variables::setVal ( std::string name,
Type new_value )

Set value of a variable in map if it exists

Template Parameters
Typetype of variable
Parameters
namename of variable
new_valuenew value for variable
Returns
none

Member Data Documentation

◆ resetters

std::map<std::string, std::function<void()> > Utilities::Variables::resetters
protected

Map of Utilities::Variable::resetValue functions captured in lambdas

◆ variables

std::map<std::string, Dynamic*> Utilities::Variables::variables
protected

Map of Utilities::Variable objects


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