Skip to content
Snippets Groups Projects
Commit 591d9b20 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

StateSelector does not inherit from GraphComponent

parent a3d7efa2
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ namespace hpp {
namespace graph {
/// This class is used to get the state of a configuration. States have to
/// be ordered because a configuration can be in several states.
class HPP_MANIPULATION_DLLAPI StateSelector : public GraphComponent
class HPP_MANIPULATION_DLLAPI StateSelector
{
public:
virtual ~StateSelector () {};
......@@ -35,6 +35,11 @@ namespace hpp {
/// Create a new StateSelector.
static StateSelectorPtr_t create(const std::string& name);
const std::string& name() const
{
return name_;
}
/// Create an empty state
StatePtr_t createState (const std::string& name, bool waypoint = false,
const int w = 0);
......@@ -54,29 +59,21 @@ namespace hpp {
/// Select randomly an outgoing edge of the given state.
virtual EdgePtr_t chooseEdge(RoadmapNodePtr_t from) const;
/// Should never be called.
void addNumericalConstraint (const constraints::ImplicitPtr_t& /* function */,
const segments_t& /* passiveDofs */ = segments_t ())
{
throw std::logic_error ("StateSelector component does not have constraints.");
}
/// Should never be called.
void addLockedJointConstraint
(const constraints::LockedJoint& /* constraint */)
{
throw std::logic_error ("StateSelector component does not have constraints.");
}
/// Print the object in a stream.
virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const;
/// Set the parent graph.
void parentGraph(const GraphWkPtr_t& parent);
/// Set the parent graph.
GraphPtr_t parentGraph() const;
protected:
/// Initialization of the object.
void init (const StateSelectorPtr_t& weak);
/// Constructor
StateSelector (const std::string& name) : GraphComponent (name)
StateSelector (const std::string& name) : name_ (name)
{}
/// Print the object in a stream.
......@@ -88,12 +85,21 @@ namespace hpp {
WeighedStates_t orderedStates_;
States_t waypoints_;
virtual void initialize () { isInit_ = true; };
private:
/// Name of the component.
std::string name_;
/// A weak pointer to the parent graph.
GraphWkPtr_t graph_;
/// Weak pointer to itself.
StateSelectorPtr_t wkPtr_;
friend std::ostream& operator<< (std::ostream& os, const StateSelector& ss);
}; // Class StateSelector
inline std::ostream& operator<< (std::ostream& os, const StateSelector& ss)
{
return ss.print(os);
}
} // namespace graph
} // namespace manipulation
} // namespace hpp
......
......@@ -138,12 +138,7 @@ namespace hpp {
std::ostream& GuidedStateSelector::print (std::ostream& os) const
{
os << "|-- ";
GraphComponent::print (os) << std::endl;
for (WeighedStates_t::const_iterator it = orderedStates_.begin();
orderedStates_.end() != it; ++it)
os << it->first << " " << *it->second;
return os;
return StateSelector::print (os);
}
} // namespace graph
} // namespace manipulation
......
......@@ -35,7 +35,6 @@ namespace hpp {
void StateSelector::init (const StateSelectorPtr_t& weak)
{
GraphComponent::init (weak);
wkPtr_ = weak;
}
......@@ -129,13 +128,24 @@ namespace hpp {
std::ostream& StateSelector::print (std::ostream& os) const
{
os << "|-- ";
GraphComponent::print (os) << std::endl;
for (WeighedStates_t::const_iterator it = orderedStates_.begin();
orderedStates_.end() != it; ++it)
os << it->first << " " << *it->second;
return os;
}
GraphPtr_t StateSelector::parentGraph() const
{
return graph_.lock ();
}
void StateSelector::parentGraph(const GraphWkPtr_t& parent)
{
graph_ = parent;
GraphPtr_t g = graph_.lock();
assert(g);
}
} // namespace graph
} // namespace manipulation
} // namespace hpp
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment