5#include "state_representation/parameters/ParameterType.hpp"
6#include "state_representation/exceptions/InvalidParameterCastException.hpp"
7#include "state_representation/exceptions/InvalidPointerException.hpp"
8#include "state_representation/State.hpp"
25 const std::string& name,
const ParameterType& type,
const StateType& parameter_state_type = StateType::NONE
62 std::shared_ptr<Parameter<T>>
get_parameter(
bool validate_pointer =
true)
const;
107 std::shared_ptr<Parameter<T>> parameter_ptr;
109 parameter_ptr = std::dynamic_pointer_cast<Parameter<T>>(std::const_pointer_cast<State>(shared_from_this()));
110 }
catch (
const std::exception&) {
111 if (validate_pointer) {
113 "Parameter interface \"" +
get_name() +
"\" is not managed by a valid pointer");
116 if (parameter_ptr ==
nullptr && validate_pointer) {
117 std::string type_name(
typeid(T).name());
119 "Unable to cast parameter interface \"" +
get_name() +
"\" to a parameter pointer of requested type "
122 return parameter_ptr;
127 return get_parameter<T>(
true)->get_value();
132 get_parameter<T>(
true)->set_value(value);
void set_parameter_value(const T &value)
Set the parameter value of a derived Parameter instance through the ParameterInterface pointer.
virtual ~ParameterInterface()=default
Default virtual destructor.
StateType get_parameter_state_type() const
Get the state type of the parameter.
std::shared_ptr< Parameter< T > > get_parameter(bool validate_pointer=true) const
Get a pointer to a derived Parameter instance from a ParameterInterface pointer.
ParameterInterface & operator=(const ParameterInterface &state)
Copy assignment operator that has to be defined to the custom assignment operator.
T get_parameter_value() const
Get the parameter value of a derived Parameter instance through the ParameterInterface pointer.
ParameterType get_parameter_type() const
Get the parameter type.
Abstract class to represent a state.
const std::string & get_name() const
Getter of the name attribute.
Core state variables and objects.
ParameterType
The parameter value types.
StateType
The class types inheriting from State.