Control Libraries 7.4.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
state_representation::ParameterMap Class Reference

A wrapper class to contain a map of Parameter pointers by name and provide robust access methods. More...

#include <ParameterMap.hpp>

Inheritance diagram for state_representation::ParameterMap:
controllers::IController< state_representation::CartesianState > dynamical_systems::IDynamicalSystem< state_representation::CartesianState > controllers::IController< S > dynamical_systems::IDynamicalSystem< S > controllers::impedance::CompliantTwist dynamical_systems::Circular dynamical_systems::Ring controllers::impedance::Impedance< state_representation::CartesianState > controllers::impedance::Impedance< S > dynamical_systems::DefaultDynamicalSystem< S > dynamical_systems::PointAttractor< S > controllers::impedance::Dissipative< state_representation::CartesianState > controllers::impedance::VelocityImpedance< state_representation::CartesianState > controllers::impedance::Dissipative< S > controllers::impedance::VelocityImpedance< S >

Public Member Functions

 ParameterMap ()=default
 Empty constructor.
 
 ParameterMap (const ParameterInterfaceList &parameters)
 Construct the parameter map with an initial list of parameters.
 
 ParameterMap (const ParameterInterfaceMap &parameters)
 Construct the parameter map with an initial map of parameters.
 
std::shared_ptr< ParameterInterfaceget_parameter (const std::string &name) const
 Get a parameter by its name.
 
ParameterInterfaceMap get_parameters () const
 Get a map of all the <name, parameter> pairs.
 
template<typename T >
get_parameter_value (const std::string &name) const
 Get a parameter value by its name.
 
ParameterInterfaceList get_parameter_list () const
 Get a list of all the parameters.
 
void set_parameter (const std::shared_ptr< ParameterInterface > &parameter)
 Set a parameter.
 
void set_parameters (const ParameterInterfaceList &parameters)
 Set parameters from a list of parameters.
 
void set_parameters (const ParameterInterfaceMap &parameters)
 Set parameters from a map with <name, parameter> pairs.
 
template<typename T >
void set_parameter_value (const std::string &name, const T &value)
 Set a parameter value by its name.
 
void remove_parameter (const std::string &name)
 Remove a parameter from the parameter map.
 

Protected Member Functions

virtual void validate_and_set_parameter (const std::shared_ptr< ParameterInterface > &parameter)
 Validate and set a parameter in the map.
 
void assert_parameter_valid (const std::shared_ptr< ParameterInterface > &parameter)
 Check if a parameter exists and has the expected type, throw an exception otherwise.
 

Protected Attributes

ParameterInterfaceMap parameters_
 map of parameters by name
 

Detailed Description

A wrapper class to contain a map of Parameter pointers by name and provide robust access methods.

Definition at line 19 of file ParameterMap.hpp.

Constructor & Destructor Documentation

◆ ParameterMap() [1/2]

ParameterMap::ParameterMap ( const ParameterInterfaceList &  parameters)
explicit

Construct the parameter map with an initial list of parameters.

Parameters
parametersA list of Parameter pointers

Definition at line 5 of file ParameterMap.cpp.

◆ ParameterMap() [2/2]

ParameterMap::ParameterMap ( const ParameterInterfaceMap &  parameters)
explicit

Construct the parameter map with an initial map of parameters.

Parameters
parametersA amp of Parameter pointers

Definition at line 9 of file ParameterMap.cpp.

Member Function Documentation

◆ assert_parameter_valid()

void ParameterMap::assert_parameter_valid ( const std::shared_ptr< ParameterInterface > &  parameter)
protected

Check if a parameter exists and has the expected type, throw an exception otherwise.

Parameters
parameterThe parameter to be validated
Exceptions
InvalidParameterExceptionif the parameter doesn't exist or has unexpected type

Definition at line 48 of file ParameterMap.cpp.

◆ get_parameter()

std::shared_ptr< ParameterInterface > ParameterMap::get_parameter ( const std::string &  name) const

Get a parameter by its name.

Parameters
nameThe name of the parameter
Returns
The parameter, if it exists

Definition at line 13 of file ParameterMap.cpp.

◆ get_parameter_list()

ParameterInterfaceList ParameterMap::get_parameter_list ( ) const

Get a list of all the parameters.

Returns
The list of parameters

Definition at line 24 of file ParameterMap.cpp.

◆ get_parameter_value()

template<typename T >
T ParameterMap::get_parameter_value ( const std::string &  name) const
inline

Get a parameter value by its name.

Template Parameters
TType of the parameter value
Parameters
nameThe name of the parameter
Returns
The value of the parameter, if the parameter exists

Definition at line 123 of file ParameterMap.hpp.

◆ get_parameters()

ParameterInterfaceMap ParameterMap::get_parameters ( ) const

Get a map of all the <name, parameter> pairs.

Returns
The map of parameters

Definition at line 20 of file ParameterMap.cpp.

◆ remove_parameter()

void ParameterMap::remove_parameter ( const std::string &  name)

Remove a parameter from the parameter map.

Parameters
nameThe name of the parameter that should be removed @raise InvalidParameterException if the parameter does not exist

Definition at line 68 of file ParameterMap.cpp.

◆ set_parameter()

void ParameterMap::set_parameter ( const std::shared_ptr< ParameterInterface > &  parameter)

Set a parameter.

Parameters
parameterThe new parameter

Definition at line 32 of file ParameterMap.cpp.

◆ set_parameter_value()

template<typename T >
void ParameterMap::set_parameter_value ( const std::string &  name,
const T &  value 
)
inline

Set a parameter value by its name.

Template Parameters
TType of the parameter value
Parameters
nameThe name of the parameter
valueThe new value of the parameter

Definition at line 128 of file ParameterMap.hpp.

◆ set_parameters() [1/2]

void ParameterMap::set_parameters ( const ParameterInterfaceList &  parameters)

Set parameters from a list of parameters.

Parameters
parametersThe list of parameters

Definition at line 36 of file ParameterMap.cpp.

◆ set_parameters() [2/2]

void ParameterMap::set_parameters ( const ParameterInterfaceMap &  parameters)

Set parameters from a map with <name, parameter> pairs.

Parameters
parametersThe map of parameters

Definition at line 42 of file ParameterMap.cpp.

◆ validate_and_set_parameter()

void ParameterMap::validate_and_set_parameter ( const std::shared_ptr< ParameterInterface > &  parameter)
protectedvirtual

Validate and set a parameter in the map.

This virtual function should be redefined in any base class to provide proper validation of parameters by name, value and type. In the base form, it allows any type of parameter name to be added to the map.

Parameters
parameterThe parameter to be validated

Definition at line 64 of file ParameterMap.cpp.

Member Data Documentation

◆ parameters_

ParameterInterfaceMap state_representation::ParameterMap::parameters_
protected

map of parameters by name

Definition at line 118 of file ParameterMap.hpp.


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