37 #ifndef OMPL_BASE_STATE_STORAGE_
38 #define OMPL_BASE_STATE_STORAGE_
40 #include "ompl/base/StateSpace.h"
41 #include <boost/archive/binary_oarchive.hpp>
42 #include <boost/archive/binary_iarchive.hpp>
43 #include <boost/serialization/vector.hpp>
44 #include <boost/function.hpp>
54 OMPL_CLASS_FORWARD(StateStorage);
73 void load(
const char *filename);
76 virtual void load(std::istream &in);
79 void store(
const char *filename);
82 virtual void store(std::ostream &out);
92 virtual void clear(
void);
95 std::size_t
size(
void)
const
109 assert(
states_.size() > index);
116 assert(
states_.size() > index);
128 void sort(
const boost::function<
bool(
const State*,
const State*)> &op);
147 virtual void print(std::ostream &out = std::cout)
const;
164 template<
typename Archive>
174 virtual void loadStates(
const Header &h, boost::archive::binary_iarchive &ia);
180 virtual void loadMetadata(
const Header &h, boost::archive::binary_iarchive &ia);
183 virtual void storeStates(
const Header &h, boost::archive::binary_oarchive &oa);
189 virtual void storeMetadata(
const Header &h, boost::archive::binary_oarchive &oa);
boost::function< StateSamplerPtr(const StateSpace *)> StateSamplerAllocator
Definition of a function that can allocate a state sampler.
Manage loading and storing for a set of states of a specified state space.
virtual void generateSamples(unsigned int count)
Generate count states uniformly at random and store them in this structure.
StateSamplerAllocator getStateSamplerAllocatorRangeAfter(std::size_t after) const
Get a sampler allocator to a sampler that can be specified for a StateSpace, such that all sampled st...
void store(const char *filename)
Save a set of states to a file.
const State * getState(unsigned int index) const
Get a particular state.
std::vector< const State * > states_
The list of maintained states.
A boost shared pointer wrapper for ompl::base::StateSpace.
std::size_t size(void) const
Return the number of stored states.
StateStorage(const StateSpacePtr &space)
The state space to store states for is specified as argument.
virtual void loadStates(const Header &h, boost::archive::binary_iarchive &ia)
Load the states from a binary archive ia, given the loaded header is h.
StateSpacePtr space_
State space that corresponds to maintained states.
StateSamplerAllocator getStateSamplerAllocator(void) const
Get a sampler allocator to a sampler that can be specified for a StateSpace, such that all sampled st...
StateSamplerAllocator getStateSamplerAllocatorRangeUntil(std::size_t until) const
Get a sampler allocator to a sampler that can be specified for a StateSpace, such that all sampled st...
virtual void loadMetadata(const Header &h, boost::archive::binary_iarchive &ia)
Load the state metadata from a binary archive ia, given the loaded header is h. No metadata is actual...
StateStorageWithMetadata< std::vector< std::size_t > > GraphStateStorage
Storage of states where the metadata is a vector of indices. This is is typically used to store a gra...
void freeMemory(void)
Free the memory allocated for states.
virtual void addState(const State *state)
Add a state to the set of states maintained by this storage structure. The state is copied to interna...
Definition of an abstract state.
const std::vector< const State * > & getStates(void) const
Get the stored states.
virtual void storeStates(const Header &h, boost::archive::binary_oarchive &oa)
Store the states to a binary archive oa, given the stored header is h.
void load(const char *filename)
Load a set of states from a specified file.
bool hasMetadata_
Flag indicating whether there is metadata associated to the states in this storage.
virtual void storeMetadata(const Header &h, boost::archive::binary_oarchive &oa)
Save the state metadata to a binary archive oa, given the stored header is h. No metadata is actually...
bool hasMetadata(void) const
Return a flag that indicates whether there is metadata associated to the states in this storage...
void sort(const boost::function< bool(const State *, const State *)> &op)
Sort the states according to the less-equal operator op. Metadata is NOT sorted; if metadata was adde...
const StateSpacePtr & getStateSpace(void) const
Get the state space this class maintains states for.
State * getState(unsigned int index)
Get a particular state for non-const access.
virtual StateSamplerAllocator getStateSamplerAllocatorRange(std::size_t from, std::size_t to) const
Get a sampler allocator to a sampler that can be specified for a StateSpace, such that all sampled st...
virtual void print(std::ostream &out=std::cout) const
Output the set of states to a specified stream, in a human readable fashion.
virtual void clear(void)
Clear the stored states. This frees all the memory.