Control Libraries 7.4.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
state_representation::ParameterInterface Class Reference
Inheritance diagram for state_representation::ParameterInterface:
state_representation::State state_representation::Parameter< bool > py_parameter::ParameterContainer state_representation::Parameter< T > state_representation::Predicate state_representation::Event

Public Member Functions

 ParameterInterface (const std::string &name, const ParameterType &type, const StateType &parameter_state_type=StateType::NONE)
 Constructor with parameter name and type.
 
 ParameterInterface (const ParameterInterface &parameter)
 Copy constructor.
 
virtual ~ParameterInterface ()=default
 Default virtual destructor.
 
ParameterInterfaceoperator= (const ParameterInterface &state)
 Copy assignment operator that has to be defined to the custom assignment operator.
 
template<typename T >
std::shared_ptr< Parameter< T > > get_parameter (bool validate_pointer=true) const
 Get a pointer to a derived Parameter instance from a ParameterInterface pointer.
 
template<typename T >
get_parameter_value () const
 Get the parameter value of a derived Parameter instance through the ParameterInterface pointer.
 
template<typename T >
void set_parameter_value (const T &value)
 Set the parameter value of a derived Parameter instance through the ParameterInterface pointer.
 
ParameterType get_parameter_type () const
 Get the parameter type.
 
StateType get_parameter_state_type () const
 Get the state type of the parameter.
 
- Public Member Functions inherited from state_representation::State
 State ()
 Empty constructor.
 
 State (const std::string &name)
 Constructor with name specification.
 
 State (const State &state)
 Copy constructor from another state.
 
virtual ~State ()=default
 Virtual destructor.
 
Stateoperator= (const State &state)
 Copy assignment operator that has to be defined to the custom assignment operator.
 
const StateTypeget_type () const
 Getter of the type attribute.
 
const std::string & get_name () const
 Getter of the name attribute.
 
bool is_empty () const
 Getter of the empty attribute.
 
const std::chrono::time_point< std::chrono::steady_clock > & get_timestamp () const
 Getter of the timestamp attribute.
 
virtual void set_name (const std::string &name)
 Setter of the name attribute.
 
void reset_timestamp ()
 Reset the timestamp attribute to now.
 
virtual void set_data (const Eigen::VectorXd &data)
 Set the data of the state from an Eigen vector.
 
virtual void set_data (const std::vector< double > &data)
 Set the data of the state from a std vector.
 
virtual void set_data (const Eigen::MatrixXd &data)
 Set the data of the state from an Eigen matrix.
 
double get_age () const
 Get the age of the state, i.e. the time since the last modification.
 
virtual bool is_incompatible (const State &state) const
 Check if the state is incompatible for operations with the state given as argument.
 
bool is_deprecated (double time_delay) const
 Check if the state is deprecated given a certain time delay.
 
template<typename DurationT >
bool is_deprecated (const std::chrono::duration< int64_t, DurationT > &time_delay) const
 Check if the state is deprecated given a certain time delay.
 
virtual void reset ()
 Reset the object to a post-construction state.
 
 operator bool () const noexcept
 Boolean operator for the truthiness of a state.
 

Additional Inherited Members

- Protected Member Functions inherited from state_representation::State
void set_type (const StateType &type)
 Setter of the state type attribute.
 
void set_empty (bool empty=true)
 Setter of the empty attribute.
 
void assert_not_empty () const
 Throw an exception if the state is empty.
 
virtual std::string to_string () const
 Convert the state to its string representation.
 

Detailed Description

Definition at line 16 of file ParameterInterface.hpp.

Constructor & Destructor Documentation

◆ ParameterInterface() [1/2]

state_representation::ParameterInterface::ParameterInterface ( const std::string &  name,
const ParameterType type,
const StateType parameter_state_type = StateType::NONE 
)

Constructor with parameter name and type.

Parameters
nameThe name of the parameter
typeThe type of the parameter
parameter_state_typeThe state type of the parameter, if applicable

Definition at line 5 of file ParameterInterface.cpp.

◆ ParameterInterface() [2/2]

state_representation::ParameterInterface::ParameterInterface ( const ParameterInterface parameter)

Copy constructor.

Parameters
parameterThe parameter to copy

Definition at line 11 of file ParameterInterface.cpp.

Member Function Documentation

◆ get_parameter()

template<typename T >
std::shared_ptr< Parameter< T > > state_representation::ParameterInterface::get_parameter ( bool  validate_pointer = true) const
inline

Get a pointer to a derived Parameter instance from a ParameterInterface pointer.

If a ParameterInterface pointer is used to address a derived Parameter instance, this method will return a pointer to that derived instance through dynamic down-casting. The downcast will fail if the base ParameterInterface object has no reference count (if the object is not owned by any pointer), or if the derived object is not a correctly typed instance of a Parameter. By default, an InvalidParameterCastException is thrown when the downcast fails. If this validation is disabled by setting the validate_pointer flag to false, it will not throw an exception and instead return a null pointer.

Template Parameters
TThe state type of the Parameter
Parameters
validate_pointerIf true, throw an exception when downcasting fails
Returns
A pointer to a derived Parameter instance of the desired state type, or a null pointer if downcasting failed and validate_pointer was set to false.

Definition at line 106 of file ParameterInterface.hpp.

◆ get_parameter_state_type()

StateType state_representation::ParameterInterface::get_parameter_state_type ( ) const

Get the state type of the parameter.

If the parameter type from get_parameter_type() is not ParameterType::STATE, this will return StateType::NONE.

Returns
The state type of the underlying parameter

Definition at line 29 of file ParameterInterface.cpp.

◆ get_parameter_type()

ParameterType state_representation::ParameterInterface::get_parameter_type ( ) const

Get the parameter type.

Returns
The type of the underlying parameter

Definition at line 25 of file ParameterInterface.cpp.

◆ get_parameter_value()

template<typename T >
T state_representation::ParameterInterface::get_parameter_value ( ) const
inline

Get the parameter value of a derived Parameter instance through the ParameterInterface pointer.

This throws an InvalidParameterCastException if the ParameterInterface does not point to a valid Parameter instance or if the specified type does not match the type of the Parameter instance.

See also
ParameterInterface::get_parameter()
Template Parameters
TThe state type of the Parameter
Returns
The value contained in the underlying Parameter instance

Definition at line 126 of file ParameterInterface.hpp.

◆ operator=()

ParameterInterface & state_representation::ParameterInterface::operator= ( const ParameterInterface state)

Copy assignment operator that has to be defined to the custom assignment operator.

Parameters
stateThe state with value to assign
Returns
Reference to the current state with new values

Definition at line 18 of file ParameterInterface.cpp.

◆ set_parameter_value()

template<typename T >
void state_representation::ParameterInterface::set_parameter_value ( const T &  value)
inline

Set the parameter value of a derived Parameter instance through the ParameterInterface pointer.

This throws an InvalidParameterCastException if the ParameterInterface does not point to a valid Parameter instance or if the specified type does not match the type of the Parameter instance.

See also
ParameterInterface::get_parameter()
Template Parameters
TThe state type of the Parameter
Parameters
valueThe value to set in the underlying Parameter instance

Definition at line 131 of file ParameterInterface.hpp.


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