State Machine
Tools for creating and running general purpose state machines.
state_machine::Settings Class Reference

#include <Settings.hpp>

Public Member Functions

 Settings ()=default
 
 ~Settings ()=default
 
void clear ()
 
yaml_tools::YamlNode toYamlNode () const
 
const ParametersgetParameters () const
 
void setParameters (const Parameters &parameters)
 
void registerParameter (const std::string &name, const std::string &type)
 
bool parameterIsRegistered (const std::string &name) const
 
void addParameter (const Parameter &parameter)
 
Parameter getParameter (const std::string &name) const
 
ParametergetParameter (const std::string &name)
 
size_t getNumberOfParameters () const
 

Static Public Member Functions

static Settings fromYamlNode (const yaml_tools::YamlNode &settingsNode)
 

Protected Types

using Parameters = std::map< std::string, Parameter >
 

Protected Attributes

Parameters parameters_
 

Detailed Description

Settings container. Can store any type of parameter which is compatible with YAML.

Member Typedef Documentation

◆ Parameters

using state_machine::Settings::Parameters = std::map<std::string, Parameter>
protected

Constructor & Destructor Documentation

◆ Settings()

state_machine::Settings::Settings ( )
default

Constructor.

◆ ~Settings()

state_machine::Settings::~Settings ( )
default

Destructor.

Member Function Documentation

◆ addParameter()

void state_machine::Settings::addParameter ( const Parameter parameter)

Add a parameter, registering it and setting its value in a single step.

Parameters
parameterParameter to add.

◆ clear()

void state_machine::Settings::clear ( )

Clear all parameters.

◆ fromYamlNode()

Settings state_machine::Settings::fromYamlNode ( const yaml_tools::YamlNode &  settingsNode)
static

Static method to create settings from a YAML node. The format must be a sequence of structs with the members name (of type string), type (of type string), and value (containing an arbitrary Yaml tree, i.e. also a single value). Example:

  • name: param1 type: double value: 1.0
  • name: param2 type: CustomType value: member1: false member2: 2.0
    Parameters
    settingsNodeSettings in YAML format.
    Returns
    Settings. Empty settings if parsing was not successful.

◆ getNumberOfParameters()

size_t state_machine::Settings::getNumberOfParameters ( ) const
inline
Returns
Number of parameters.

◆ getParameter() [1/2]

Parameter state_machine::Settings::getParameter ( const std::string &  name) const

Get a parameter.

Parameters
nameName of the parameter to get.
Returns
Parameter.

◆ getParameter() [2/2]

Parameter & state_machine::Settings::getParameter ( const std::string &  name)

Get a parameter by reference.

Parameters
nameName of the parameter to get.
Returns
Reference to parameter.

◆ getParameters()

const Settings::Parameters & state_machine::Settings::getParameters ( ) const

Get all parameters.

Returns
All parameters.

◆ parameterIsRegistered()

bool state_machine::Settings::parameterIsRegistered ( const std::string &  name) const

Check if a parameter has been registered.

Parameters
nameName of the parameter to check for.
Returns
True if it has been registered.

◆ registerParameter()

void state_machine::Settings::registerParameter ( const std::string &  name,
const std::string &  type 
)

Register a new parameter, not setting a value yet. This is useful for checking the parameters a state offers.

Parameters
nameName of the parameter.
typeType of the parameter.

◆ setParameters()

void state_machine::Settings::setParameters ( const Parameters parameters)

Set all parameters.

Parameters
parametersAll parameters.

◆ toYamlNode()

yaml_tools::YamlNode state_machine::Settings::toYamlNode ( ) const

Convert the settings into a YAML node.

Returns
Settings in YAML node format.

Member Data Documentation

◆ parameters_

Parameters state_machine::Settings::parameters_
protected

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