3 #include "aikido/statespace/CartesianProduct.hpp" 10 template <
class _QualifiedState>
11 class CompoundStateHandle
12 :
public statespace::StateHandle<CartesianProduct, _QualifiedState>
15 using typename statespace::StateHandle<CartesianProduct, _QualifiedState>::
17 using typename statespace::StateHandle<CartesianProduct, _QualifiedState>::
19 using typename statespace::StateHandle<CartesianProduct, _QualifiedState>::
43 template <
class Space = statespace::StateSpace>
55 template <
class Space = statespace::StateSpace>
56 const typename Space::State*
getSubState(std::size_t _index)
const 68 template <
class Space = statespace::StateSpace>
71 return typename Space::StateHandle(
72 this->
getStateSpace()->
template getSubspace<Space>(_index).
get(),
73 getSubState<Space>(_index));
82 template <
class Space = statespace::StateSpace>
85 return typename Space::StateHandleConst(
86 this->
getStateSpace()->
template getSubspace<Space>(_index).
get(),
87 getSubState<Space>(_index));
92 template <
class Space>
94 std::size_t _index)
const 97 const auto rawSpace = mSubspaces[_index];
98 auto space = std::dynamic_pointer_cast<
const Space>(rawSpace);
103 const auto& rawSpaceValue = *rawSpace;
105 std::stringstream ss;
106 ss <<
"Requested StateSpace of type '" <<
typeid(Space).name()
107 <<
"', but the StateSpace at index " << _index
108 <<
" is of incompatible type '" <<
typeid(rawSpaceValue).name() <<
"'.";
109 throw std::runtime_error(ss.str());
115 template <
class Space>
117 State* _state, std::size_t _index)
const 122 return reinterpret_cast<typename Space::State*
>(
123 reinterpret_cast<char*
>(_state) + mOffsets[_index]);
127 template <
class Space>
129 const State* _state, std::size_t _index)
const 134 return reinterpret_cast<const typename Space::State*
>(
135 reinterpret_cast<const char*
>(_state) + mOffsets[_index]);
139 template <
class Space>
141 State* _state, std::size_t _index)
const 143 return typename Space::StateHandle(
144 getSubspace<Space>(_index).
get(), getSubState<Space>(_state, _index));
148 template <
class Space>
150 const State* _state, std::size_t _index)
const 152 return typename Space::StateHandleConst(
153 getSubspace<Space>(_index).
get(), getSubState<Space>(_state, _index));
Space::State * getSubState(State *_state, std::size_t _index) const
Gets substate of type Space::State from a CompoundState by index.
Definition: CartesianProduct-impl.hpp:116
Wrap a State with its StateSpace to provide convenient accessor methods.
Definition: StateHandle.hpp:16
Space::State * getSubState(std::size_t _index)
Gets state by subspace index.
Definition: CartesianProduct-impl.hpp:44
Represents the Cartesian product of other StateSpaces.
Definition: CartesianProduct.hpp:18
CompoundStateHandle(const StateSpace *_space, State *_state)
Construct a handle for _state in _space.
Definition: CartesianProduct-impl.hpp:32
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
Space::StateHandleConst getSubStateHandle(std::size_t _index) const
Gets state by subspace index and wraps it in a Space::StateHandle helper class.
Definition: CartesianProduct-impl.hpp:83
const StateSpace * getStateSpace() const
Returns the state space that created this state.
Definition: StateHandle-impl.hpp:66
Space::StateHandle getSubStateHandle(State *_state, std::size_t _index) const
Gets substate of type Space::State from a CompoundState by index and wraps it in a Space::StateHandle...
Definition: CartesianProduct-impl.hpp:140
A tuple of states where the i-th state is from the i-th subspace.
Definition: CartesianProduct.hpp:162
CompoundStateHandle()
Construct and initialize to nullptr.
Definition: CartesianProduct-impl.hpp:23
Space::StateHandle getSubStateHandle(std::size_t _index)
Gets state by subspace index and wraps it in a Space::StateHandle helper class.
Definition: CartesianProduct-impl.hpp:69
std::shared_ptr< const Space > getSubspace(std::size_t _index) const
Gets subspace of type Space by at _index.
Definition: CartesianProduct-impl.hpp:93
const Space::State * getSubState(std::size_t _index) const
Gets state by subspace index.
Definition: CartesianProduct-impl.hpp:56
auto getState() -> typename std::enable_if<!std::is_const< Q >::value, Q * >::type
Returns the State.
Definition: StateHandle-impl.hpp:49