iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::StateAccessor< Head, Tail...> Class Template Reference

#include <nrt/Probabilistic/Types/StateDef.H>

template<typename Head, typename... Tail>
class nrt::StateAccessor< Head, Tail...>

Helper of StateDef which provides access to elements by their type.

Definition at line 147 of file StateDef.H.

Inherits nrt::StateAccessorCore< Element >, and nrt::StateAccessor< Elements >.

Public Member Functions

 StateAccessor (double data[])
 Constructor, used by State, should not be of general interest but left public for now.
 
template<typename Elem >
std::enable_if< std::is_same
< Elem, Head >::value, Elem & >
::type 
get ()
 Get an element by type name. More...
 
template<typename Elem >
std::enable_if<!std::is_same
< Elem, Head >::value, Elem & >
::type 
get ()
 Get an element by type name (SFINAE recursion function when Elem is not the Head)
 
template<typename Elem >
std::enable_if< std::is_same
< Elem, Head >::value, Elem
const & >::type 
get () const
 Get an element by type name, const version.
 
template<typename Elem >
std::enable_if<!std::is_same
< Elem, Head >::value, Elem
const & >::type 
get () const
 Get an element by type name, const version (SFINAE recursion function when Elem is not the Head)
 
template<typename Elem >
std::enable_if< std::is_same
< Elem, Head >::value, size_t
const >::type 
index () const
 Get the index in our Eigen vector of a particular leaf double& element.
 
template<typename Elem >
std::enable_if<!std::is_same
< Elem, Head >::value, size_t
const >::type 
index () const
 Get the index in our Eigen vector of a particular leaf double& element (SFINAE)
 
void print (std::ostream &os) const
 Recursively print our structure and contents.
 
- Public Member Functions inherited from nrt::StateAccessorCore< Element >
 StateAccessorCore (double data[])
 
Element & get ()
 
Element const & get () const
 

Static Public Attributes

static size_t const size = Head::size + StateAccessor<Tail...>::size
 The compile-time-known size of the state, in number of double-type elements (not in bytes)
 
- Static Public Attributes inherited from nrt::StateAccessorCore< Element >
static size_t const size = Element::size
 

Member Function Documentation

template<typename Head , typename... Tail>
template<class Elem >
std::enable_if< std::is_same< Elem, Head >::value, Elem & >::type nrt::StateAccessor< Head, Tail...>::get ( )
inline

Get an element by type name.

Beware that you should not have repeated elements of the same type in a State, otherwise this will always return the first match. Use nested State structures or different types. Example:

typedef State<Pos3D, Vel3D> myState;
myState::datatype data; // allocate some Eigen vector to actually store the data
myState state(data); // attach a State to it, which will allow easy named access to data elements
state.get<Pos3D>().x = 1.0;
state.get<Vel3D>().vz = 6.0;

Definition at line 48 of file StateDefImpl.H.


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