Template Class ScopedState
Defined in File ScopedState.h
Class Documentation
-
template<class T = StateSpace>
class ScopedState Definition of a scoped state.
This class allocates a state of a desired type using the allocation mechanism of the corresponding state space. The state is then freed when the instance goes out of scope using the corresponding free mechanism.
Public Functions
-
inline explicit ScopedState(const SpaceInformationPtr &si)
Given the space that we are working with, allocate a state from the corresponding state space.
-
inline explicit ScopedState(StateSpacePtr space)
Given the state space that we are working with, allocate a state.
-
inline ScopedState(const ScopedState<T> &other)
Copy constructor.
-
template<class O>
inline ScopedState(const ScopedState<O> &other) Copy constructor that allows instantiation from states of other type.
-
inline ScopedState(StateSpacePtr space, const State *state)
Given the state space that we are working with, allocate a state and fill that state with a given value.
-
inline ~ScopedState()
Free the memory of the internally allocated state.
-
inline const StateSpacePtr &getSpace() const
Get the state space that the state corresponds to.
-
inline ScopedState<T> &operator=(const ScopedState<T> &other)
Assignment operator.
-
inline ScopedState<T> &operator=(const State *other)
Assignment operator.
-
inline ScopedState<T> &operator=(const State &other)
Assignment operator.
-
template<class O>
inline ScopedState<T> &operator=(const ScopedState<O> &other) Assignment operator that allows conversion of states.
-
inline ScopedState<T> &operator=(const std::vector<double> &reals)
Partial assignment operator. Only sets the double values of the state to specified real values.
-
inline ScopedState<T> &operator=(const double value)
Partial assignment operator. Only sets the double values of the state to a fixed value.
-
template<class O>
inline bool operator==(const ScopedState<O> &other) const Checks equality of two states.
-
template<class O>
inline bool operator!=(const ScopedState<O> &other) const Checks equality of two states.
-
const ScopedState operator[](const StateSpacePtr &s) const
Extract a state that corresponds to the components in state space s. Those components will have the same value as the current state (only the ones included in the current state; others will be uninitialised). Note: a new state is constructed and data is copied.
-
inline double &operator[](const unsigned int index)
Access the index double value this state contains.
-
inline double operator[](const unsigned int index) const
Access the index double value this state contains.
-
inline double &operator[](const std::string &name)
Access a double value from this state contains using its name.
-
inline double operator[](const std::string &name) const
Access a double value from this state contains using its name.
-
template<class O>
inline double distance(const ScopedState<O> &other) const Compute the distance to another state.
-
inline void random()
Set this state to a random value (uniform)
-
inline void enforceBounds()
Enforce the bounds on the maintained state.
-
inline bool satisfiesBounds() const
Check if the maintained state satisfies bounds.
-
inline std::vector<double> reals() const
Return the real values corresponding to this state. If a conversion is not possible, an exception is thrown.
-
inline void print(std::ostream &out = std::cout) const
Print this state to a stream.
-
inline explicit ScopedState(const SpaceInformationPtr &si)