From abb8d5c715c4c938ddea6fe36e85b0331083eccb Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Fri, 8 Aug 2014 16:02:42 +0200 Subject: [PATCH] Change keywords (virtual, const) in declaration of GraphComponents --- include/hpp/manipulation/graph/graph.hh | 10 +++++----- include/hpp/manipulation/graph/node-selector.hh | 8 ++++---- include/hpp/manipulation/graph/node.hh | 2 +- src/graph/graph.cc | 6 +++--- src/graph/node-selector.cc | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/hpp/manipulation/graph/graph.hh b/include/hpp/manipulation/graph/graph.hh index 0fc6144c..2fa1ee25 100644 --- a/include/hpp/manipulation/graph/graph.hh +++ b/include/hpp/manipulation/graph/graph.hh @@ -45,27 +45,27 @@ namespace hpp { NodeSelectorPtr_t createNodeSelector(); /// Returns the states of a configuration. - virtual Nodes_t getNode(const Configuration_t config); + Nodes_t getNode(const Configuration_t config) const; /// Select randomly outgoing edges of the given nodes. - virtual Edges_t chooseEdge(const Nodes_t& node); + Edges_t chooseEdge(const Nodes_t& node) const; /// Constraint to project onto the Nodes_t. /// \param the Nodes_t on which to project. /// \return The initialized projector. - virtual ConstraintSetPtr_t configConstraint (const Nodes_t& nodes); + ConstraintSetPtr_t configConstraint (const Nodes_t& nodes); /// Constraint to project onto the same leaf as config. /// \param edges a list of edges defining the foliation. /// \param config Configuration that will initialize the projector. /// \return The initialized projector. - virtual ConstraintSetPtr_t configConstraint (const Edges_t& edges, ConfigurationIn_t config); + ConstraintSetPtr_t configConstraint (const Edges_t& edges, ConfigurationIn_t config); /// Constraint to project a path. /// \param edges a list of edges defining the foliation. /// \param config Configuration that will initialize the constraint. /// \return The initialized constraint. - virtual ConstraintSetPtr_t pathConstraint (const Edges_t& edges, ConfigurationIn_t config); + ConstraintSetPtr_t pathConstraint (const Edges_t& edges, ConfigurationIn_t config); /// Return the NodeSelector with the given name if any, /// NULL pointer if not found. diff --git a/include/hpp/manipulation/graph/node-selector.hh b/include/hpp/manipulation/graph/node-selector.hh index df4144c2..bbe44623 100644 --- a/include/hpp/manipulation/graph/node-selector.hh +++ b/include/hpp/manipulation/graph/node-selector.hh @@ -37,22 +37,22 @@ namespace hpp { NodePtr_t createNode (); /// Returns the state of a configuration. - virtual NodePtr_t getNode(const Configuration_t config); + NodePtr_t getNode(const Configuration_t config) const; /// Select randomly an outgoing edge of the given node. - virtual EdgePtr_t chooseEdge(const NodePtr_t& node); + virtual EdgePtr_t chooseEdge(const NodePtr_t& node) const; /// Print the object in a stream. std::ostream& print (std::ostream& os) const; /// Should never be called. - virtual void addNumericalConstraint (const core::DifferentiableFunctionPtr_t& /* function */) + void addNumericalConstraint (const core::DifferentiableFunctionPtr_t& /* function */) { HPP_THROW_EXCEPTION (Bad_function_call, "This component does not have constraints."); } /// Should never be called. - virtual void addLockedDofConstraint (const core::LockedDof& /* constraint */) + void addLockedDofConstraint (const core::LockedDof& /* constraint */) { HPP_THROW_EXCEPTION (Bad_function_call, "This component does not have constraints."); } diff --git a/include/hpp/manipulation/graph/node.hh b/include/hpp/manipulation/graph/node.hh index 32784f41..db5b24b5 100644 --- a/include/hpp/manipulation/graph/node.hh +++ b/include/hpp/manipulation/graph/node.hh @@ -52,7 +52,7 @@ namespace hpp { virtual bool contains (const Configuration_t config); /// Get the parent NodeSelector. - NodeSelectorWkPtr_t nodeSelector () + NodeSelectorWkPtr_t nodeSelector () const { return selector_; } diff --git a/src/graph/graph.cc b/src/graph/graph.cc index c64a4df2..e61e28df 100644 --- a/src/graph/graph.cc +++ b/src/graph/graph.cc @@ -73,16 +73,16 @@ namespace hpp { return robot_; } - Nodes_t Graph::getNode(const Configuration_t config) + Nodes_t Graph::getNode(const Configuration_t config) const { Nodes_t nodes; - for (NodeSelectors_t::iterator it = nodeSelectors_.begin(); + for (NodeSelectors_t::const_iterator it = nodeSelectors_.begin(); it != nodeSelectors_.end(); it++) nodes.push_back( (*it)->getNode(config) ); return nodes; } - Edges_t Graph::chooseEdge(const Nodes_t& nodes) + Edges_t Graph::chooseEdge(const Nodes_t& nodes) const { Edges_t edges; for (Nodes_t::const_iterator it = nodes.begin(); diff --git a/src/graph/node-selector.cc b/src/graph/node-selector.cc index 141bcd91..909ed653 100644 --- a/src/graph/node-selector.cc +++ b/src/graph/node-selector.cc @@ -44,16 +44,16 @@ namespace hpp { return newNode; } - NodePtr_t NodeSelector::getNode(const Configuration_t config) + NodePtr_t NodeSelector::getNode(const Configuration_t config) const { - for (Nodes_t::iterator it = orderedStates_.begin(); + for (Nodes_t::const_iterator it = orderedStates_.begin(); orderedStates_.end() != it; it++) if ((*it)->contains(config)) return *it; return NodePtr_t (); } - EdgePtr_t NodeSelector::chooseEdge(const NodePtr_t& node) + EdgePtr_t NodeSelector::chooseEdge(const NodePtr_t& node) const { const Edges_t neighbors = node->neighbors(); size_t n = rand() % neighbors.size(); -- GitLab