Control Libraries 7.4.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
state_representation::IOState< T > Class Template Reference
Inheritance diagram for state_representation::IOState< T >:
state_representation::State

Public Member Functions

unsigned int get_size () const
 Getter of the size.
 
const std::vector< std::string > & get_names () const
 Getter of the names.
 
unsigned int get_io_index (const std::string &io_name) const
 Get IO index by the name of the IO, if it exists.
 
get_value (const std::string &name) const
 Get the value of an IO by its name, if it exists.
 
get_value (unsigned int io_index) const
 Get the value of an IO by its index, if it exists.
 
Eigen::Vector< T, Eigen::Dynamic > data () const
 Returns the values of the IO state as an Eigen vector.
 
Eigen::Array< T, Eigen::Dynamic, 1 > array () const
 Returns the values of the IO state an Eigen array.
 
void set_names (unsigned int nb_ios)
 Setter of the names from the number of IOs.
 
void set_names (const std::vector< std::string > &names)
 Setter of the names from a list of IO names.
 
void set_value (T value, const std::string &name)
 Set the value of an IO by its name.
 
void set_value (T value, unsigned int io_index)
 Set the value of an IO by its index.
 
void set_data (const Eigen::Vector< T, Eigen::Dynamic > &data)
 Set the values of the IO state from a single Eigen vector.
 
void set_data (const std::vector< T > &data)
 Set the values of the IO state from a single std vector.
 
bool is_incompatible (const State &state) const override
 Check if the IO group is incompatible for operations with the state given as argument.
 
std::vector< T > to_std_vector () const
 Return the IO values as a std vector.
 
void set_data (const std::vector< double > &data)
 Set the data of the state from a std vector.
 
void set_data (const std::vector< bool > &data)
 
std::vector< double > to_std_vector () const
 
std::vector< bool > to_std_vector () const
 
- 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 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.
 
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.
 

Protected Member Functions

 IOState ()=default
 Empty constructor for an IO state.
 
 IOState (const std::string &name, unsigned int nb_ios)
 Constructor with name and number of IOs provided.
 
 IOState (const std::string &name, const std::vector< std::string > &io_names)
 Constructor with name and list of IO names provided.
 
- 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.
 

Static Protected Member Functions

static void assert_index_in_range (unsigned int io_index, unsigned int size)
 

Protected Attributes

std::vector< std::string > names_
 names of the IOs
 
Eigen::Vector< T, Eigen::Dynamic > data_
 IO values.
 

Friends

void swap (IOState &state1, IOState &state2)
 Swap the values of the IO states.
 

Detailed Description

template<typename T>
class state_representation::IOState< T >

Definition at line 12 of file IOState.hpp.

Constructor & Destructor Documentation

◆ IOState() [1/2]

template<typename T >
state_representation::IOState< T >::IOState ( const std::string &  name,
unsigned int  nb_ios 
)
explicitprotected

Constructor with name and number of IOs provided.

Parameters
nameThe name of the associated IO state
nb_iosThe number of IOs for initialization

Definition at line 149 of file IOState.hpp.

◆ IOState() [2/2]

template<typename T >
state_representation::IOState< T >::IOState ( const std::string &  name,
const std::vector< std::string > &  io_names 
)
protected

Constructor with name and list of IO names provided.

Parameters
nameThe name of the associated IO state
io_nameList of IO names

Definition at line 156 of file IOState.hpp.

Member Function Documentation

◆ array()

template<typename T >
Eigen::Array< T, Eigen::Dynamic, 1 > state_representation::IOState< T >::array ( ) const

Returns the values of the IO state an Eigen array.

Definition at line 199 of file IOState.hpp.

◆ assert_index_in_range()

template<typename T >
void state_representation::IOState< T >::assert_index_in_range ( unsigned int  io_index,
unsigned int  size 
)
staticprotected

Definition at line 269 of file IOState.hpp.

◆ data()

template<typename T >
Eigen::Vector< T, Eigen::Dynamic > state_representation::IOState< T >::data ( ) const

Returns the values of the IO state as an Eigen vector.

Definition at line 193 of file IOState.hpp.

◆ get_io_index()

template<typename T >
unsigned int state_representation::IOState< T >::get_io_index ( const std::string &  io_name) const

Get IO index by the name of the IO, if it exists.

Parameters
io_nameThe name of the desired IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The index of the IO, if it exists

Definition at line 172 of file IOState.hpp.

◆ get_names()

template<typename T >
const std::vector< std::string > & state_representation::IOState< T >::get_names ( ) const

Getter of the names.

Returns
The vector of strings containing the IO names

Definition at line 167 of file IOState.hpp.

◆ get_size()

template<typename T >
unsigned int state_representation::IOState< T >::get_size ( ) const

Getter of the size.

Definition at line 162 of file IOState.hpp.

◆ get_value() [1/2]

template<typename T >
T state_representation::IOState< T >::get_value ( const std::string &  name) const

Get the value of an IO by its name, if it exists.

Parameters
nameThe name of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The value of the IO, if it exists

Definition at line 181 of file IOState.hpp.

◆ get_value() [2/2]

template<typename T >
T state_representation::IOState< T >::get_value ( unsigned int  io_index) const

Get the value of an IO by its index, if it exists.

Parameters
io_indexThe index of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist
Returns
The value of the IO, if it exists

Definition at line 186 of file IOState.hpp.

◆ is_incompatible()

template<typename T >
bool state_representation::IOState< T >::is_incompatible ( const State state) const
overridevirtual

Check if the IO group is incompatible for operations with the state given as argument.

Parameters
stateThe state to check compatibility with

Reimplemented from state_representation::State.

Definition at line 251 of file IOState.hpp.

◆ set_data() [1/4]

template<typename T >
void state_representation::IOState< T >::set_data ( const Eigen::Vector< T, Eigen::Dynamic > &  data)

Set the values of the IO state from a single Eigen vector.

Parameters
Thedata vector

Definition at line 240 of file IOState.hpp.

◆ set_data() [2/4]

void state_representation::IOState< bool >::set_data ( const std::vector< bool > &  data)

Definition at line 11 of file IOState.cpp.

◆ set_data() [3/4]

void state_representation::IOState< double >::set_data ( const std::vector< double > &  data)
virtual

Set the data of the state from a std vector.

Reimplemented from state_representation::State.

Definition at line 6 of file IOState.cpp.

◆ set_data() [4/4]

template<typename T >
void state_representation::IOState< T >::set_data ( const std::vector< T > &  data)

Set the values of the IO state from a single std vector.

Parameters
Thedata vector

◆ set_names() [1/2]

template<typename T >
void state_representation::IOState< T >::set_names ( const std::vector< std::string > &  names)

Setter of the names from a list of IO names.

Parameters
namesThe vector of strings containing the IO names

Definition at line 217 of file IOState.hpp.

◆ set_names() [2/2]

template<typename T >
void state_representation::IOState< T >::set_names ( unsigned int  nb_ios)

Setter of the names from the number of IOs.

Parameters
nb_iosThe number of IOs of the IO state

Definition at line 204 of file IOState.hpp.

◆ set_value() [1/2]

template<typename T >
void state_representation::IOState< T >::set_value ( value,
const std::string &  name 
)

Set the value of an IO by its name.

Parameters
valueThe value of the IO
nameThe name of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist

Definition at line 228 of file IOState.hpp.

◆ set_value() [2/2]

template<typename T >
void state_representation::IOState< T >::set_value ( value,
unsigned int  io_index 
)

Set the value of an IO by its index.

Parameters
valueThe value of the IO
io_indexThe index of the IO
Exceptions
IONotFoundExceptionif the desired IO doesn't exist

Definition at line 233 of file IOState.hpp.

◆ to_std_vector() [1/3]

template<typename T >
std::vector< T > state_representation::IOState< T >::to_std_vector ( ) const

Return the IO values as a std vector.

Returns
The IO values as a std vector

◆ to_std_vector() [2/3]

std::vector< double > state_representation::IOState< double >::to_std_vector ( ) const

Definition at line 21 of file IOState.cpp.

◆ to_std_vector() [3/3]

std::vector< bool > state_representation::IOState< bool >::to_std_vector ( ) const

Definition at line 26 of file IOState.cpp.

Friends And Related Symbol Documentation

◆ swap

template<typename T >
void swap ( IOState< T > &  state1,
IOState< T > &  state2 
)
friend

Swap the values of the IO states.

Parameters
state1IO state to be swapped with 2
state2IO state to be swapped with 1

Definition at line 136 of file IOState.hpp.

Member Data Documentation

◆ data_

template<typename T >
Eigen::Vector<T, Eigen::Dynamic> state_representation::IOState< T >::data_
protected

IO values.

Definition at line 145 of file IOState.hpp.

◆ names_

template<typename T >
std::vector<std::string> state_representation::IOState< T >::names_
protected

names of the IOs

Definition at line 144 of file IOState.hpp.


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