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

Add pure virtual GraphComponent::constraints method

parent bee9cb88
No related branches found
No related tags found
No related merge requests found
......@@ -33,9 +33,12 @@ namespace hpp {
class HPP_MANIPULATION_DLLAPI Edge : public GraphComponent
{
public:
/// Create a new Edge.
static EdgePtr_t create (const NodeWkPtr_t& from, const NodeWkPtr_t& to,
const ConstraintPtr_t& constraints);
/// Create a new empty Edge.
static EdgePtr_t create (const NodeWkPtr_t& from, const NodeWkPtr_t& to);
/// Set the constraints of the Edge.
void constraints (const ConstraintPtr_t& constraints)
throw (Bad_function_call);
/// Projector to project onto the same leaf as config.
/// \return The initialized projector.
......@@ -53,7 +56,7 @@ namespace hpp {
protected:
/// Initialization of the object.
void init (const EdgeWkPtr_t& weak, const NodeWkPtr_t& from,
const NodeWkPtr_t& to, const ConstraintPtr_t& constraints);
const NodeWkPtr_t& to);
/// Constructor
Edge()
......
......@@ -32,6 +32,7 @@ namespace hpp {
typedef boost::shared_ptr < Node > NodePtr_t;
typedef boost::shared_ptr < Edge > EdgePtr_t;
typedef boost::shared_ptr < NodeSelector > NodeSelectorPtr_t;
typedef boost::shared_ptr < GraphComponent > GraphComponentPtr_t;
typedef std::vector < NodePtr_t > Nodes_t;
typedef std::vector < EdgePtr_t > Edges_t;
typedef std::vector < NodeSelectorPtr_t > NodeSelectors_t;
......
......@@ -20,6 +20,7 @@
# include <string>
# include <ostream>
# include <hpp/util/assertion.hh>
# include <hpp/util/exception.hh>
# include "hpp/manipulation/robot.hh"
......@@ -30,6 +31,8 @@
namespace hpp {
namespace manipulation {
namespace graph {
HPP_MAKE_EXCEPTION ( HPP_MANIPULATION_DLLAPI, Bad_function_call );
/// Define common methods of the graph components.
class HPP_MANIPULATION_DLLAPI GraphComponent
{
......@@ -61,10 +64,11 @@ namespace hpp {
}
/// Print the object in a stream.
virtual std::ostream& print (std::ostream& os) const
{
return os;
}
virtual std::ostream& print (std::ostream& os) const = 0;
/// Set the constraints of the component.
virtual void constraints (const ConstraintPtr_t& /* constraints */)
throw (Bad_function_call) = 0;
protected:
void init (const GraphComponentWkPtr_t& weak)
......@@ -119,6 +123,13 @@ namespace hpp {
/// Print the object in a stream.
std::ostream& print (std::ostream& os) const;
/// Should never be called.
virtual void constraints (const ConstraintPtr_t& /* constraints */)
throw (Bad_function_call)
{
HPP_THROW_EXCEPTION (Bad_function_call, "This component does not have constraints.");
}
protected:
/// Initialization of the object.
void init (const GraphWkPtr_t& weak, RobotPtr_t robot);
......
......@@ -48,6 +48,12 @@ namespace hpp {
/// Print the object in a stream.
std::ostream& print (std::ostream& os) const;
/// Should never be called.
virtual void constraints (const ConstraintPtr_t& /* constraints */)
throw (Bad_function_call)
{
HPP_THROW_EXCEPTION (Bad_function_call, "This component does not have constraints.");
}
protected:
/// Initialization of the object.
void init (const NodeSelectorPtr_t& weak);
......
......@@ -40,7 +40,7 @@ namespace hpp {
static NodePtr_t create (const ConstraintPtr_t& constraints);
/// Create a link from this node to the given node.
EdgePtr_t linkTo(const NodePtr_t& to, const ConstraintPtr_t& constraints);
EdgePtr_t linkTo(const NodePtr_t& to);
/// Check whether the configuration is in this state.
/// \return True if this state contains this configuration
......@@ -58,9 +58,7 @@ namespace hpp {
/// Set the constraint set associated to the node.
void constraints (const ConstraintPtr_t& constraints)
{
constraints_ = constraints;
}
throw (Bad_function_call);
/// Get the parent NodeSelector.
NodeSelectorWkPtr_t nodeSelector ()
......@@ -90,6 +88,7 @@ namespace hpp {
/// Initialize the object.
void init (const NodeWkPtr_t& self, const ConstraintPtr_t& constraints);
/// Constructor
Node()
{}
......
......@@ -19,23 +19,27 @@
namespace hpp {
namespace manipulation {
namespace graph {
EdgePtr_t Edge::create (const NodeWkPtr_t& from, const NodeWkPtr_t& to,
const ConstraintPtr_t& constraints)
EdgePtr_t Edge::create (const NodeWkPtr_t& from, const NodeWkPtr_t& to)
{
Edge* ptr = new Edge;
EdgePtr_t shPtr (ptr);
ptr->init(shPtr, from, to, constraints);
ptr->init(shPtr, from, to);
return shPtr;
}
void Edge::constraints (const ConstraintPtr_t& constraint)
throw (Bad_function_call)
{
constraints_ = constraint;
}
void Edge::init (const EdgeWkPtr_t& weak, const NodeWkPtr_t& from,
const NodeWkPtr_t& to, const ConstraintPtr_t& constraints)
const NodeWkPtr_t& to)
{
GraphComponent::init (weak);
wkPtr_ = weak;
from_ = from;
to_ = to;
constraints_ = constraints;
}
std::ostream& Edge::print (std::ostream& os) const
......
......@@ -47,9 +47,15 @@ namespace hpp {
constraints(constraint);
}
EdgePtr_t Node::linkTo(const NodePtr_t& to, const ConstraintPtr_t& constraints)
void Node::constraints (const ConstraintPtr_t& constraint)
throw (Bad_function_call)
{
EdgePtr_t newEdge = Edge::create(wkPtr_, to, constraints);
constraints_ = constraint;
}
EdgePtr_t Node::linkTo(const NodePtr_t& to)
{
EdgePtr_t newEdge = Edge::create(wkPtr_, to);
neighbors_.push_back(newEdge);
return newEdge;
}
......
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