aikido
ScopedState-impl.hpp
1 #include "aikido/statespace/ScopedState.hpp"
2 
3 namespace aikido {
4 namespace statespace {
5 
6 //==============================================================================
7 template <class Handle>
9 {
10  this->mSpace = _space;
11  mBuffer.reset(new char[_space->getStateSizeInBytes()]);
12  this->mState = static_cast<ScopedState::State*>(
13  _space->allocateStateInBuffer(mBuffer.get()));
14 }
15 
16 //==============================================================================
17 template <class Handle>
19 {
20  this->mSpace->freeStateInBuffer(this->mState);
21 }
22 
23 //==============================================================================
24 template <class Handle>
26 {
27  return this->mSpace->cloneState(this->mState);
28 }
29 
30 } // namespace statespace
31 } // namespace aikido
CRTP RAII wrapper for a StateHandle.
Definition: ScopedState.hpp:15
ScopedState(const StateSpace *_space)
Construct a ScopedState by allocating a new state in _space.
Definition: ScopedState-impl.hpp:8
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
virtual std::size_t getStateSizeInBytes() const =0
Gets the size of a State, in bytes.
Represents a Lie group and its associated Lie algebra, i.e.
Definition: StateSpace.hpp:33
virtual State * allocateStateInBuffer(void *_buffer) const =0
Create a new state in a pre-allocated buffer.
ScopedState clone() const
Creates an identical clone of the state this ScopedState handles.
Definition: ScopedState-impl.hpp:25