From 245670f507d234a343f5f2fe6a57696d64045963 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Tue, 4 Jul 2017 17:05:56 +0200 Subject: [PATCH] GraphSteeringMethod is built with a const Problem& (not a ProblemPtr_t) --- include/hpp/manipulation/graph-steering-method.hh | 14 +++++++------- src/graph-steering-method.cc | 13 ++++++------- src/problem.cc | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/hpp/manipulation/graph-steering-method.hh b/include/hpp/manipulation/graph-steering-method.hh index 29a750cc..42d96c6b 100644 --- a/include/hpp/manipulation/graph-steering-method.hh +++ b/include/hpp/manipulation/graph-steering-method.hh @@ -38,16 +38,16 @@ namespace hpp { public: /// Create instance and return shared pointer - /// \warning core::ProblemPtr_t will be casted to ProblemPtr_t + /// \warning core::Problem will be casted to Problem static GraphSteeringMethodPtr_t create - (const core::ProblemPtr_t& problem); + (const core::Problem& problem); template <typename T> static GraphSteeringMethodPtr_t create - (const core::ProblemPtr_t& problem); + (const core::Problem& problem); /// Create instance and return shared pointer - static GraphSteeringMethodPtr_t create (const ProblemPtr_t& problem); + static GraphSteeringMethodPtr_t create (const Problem& problem); /// Create copy and return shared pointer static GraphSteeringMethodPtr_t createCopy @@ -71,7 +71,7 @@ namespace hpp { protected: /// Constructor - GraphSteeringMethod (const ProblemPtr_t& problem); + GraphSteeringMethod (const Problem& problem); /// Copy constructor GraphSteeringMethod (const GraphSteeringMethod&); @@ -86,7 +86,7 @@ namespace hpp { private: /// A pointer to the problem - ProblemPtr_t problem_; + const Problem& problem_; /// Weak pointer to itself GraphSteeringMethodWkPtr_t weak_; /// The encapsulated steering method @@ -95,7 +95,7 @@ namespace hpp { template <typename T> GraphSteeringMethodPtr_t GraphSteeringMethod::create - (const core::ProblemPtr_t& problem) + (const core::Problem& problem) { GraphSteeringMethodPtr_t gsm = GraphSteeringMethod::create (problem); gsm->innerSteeringMethod (T::create (problem)); diff --git a/src/graph-steering-method.cc b/src/graph-steering-method.cc index 09f42b40..c52f8e5f 100644 --- a/src/graph-steering-method.cc +++ b/src/graph-steering-method.cc @@ -27,16 +27,15 @@ namespace hpp { namespace manipulation { GraphSteeringMethodPtr_t GraphSteeringMethod::create - (const core::ProblemPtr_t& problem) + (const core::Problem& problem) { - assert (dynamic_cast <const ProblemPtr_t> (problem) != NULL - && "Cast to const ProblemPtr_t failed"); - const ProblemPtr_t& p = static_cast <const ProblemPtr_t> (problem); + dynamic_cast <const Problem&> (problem); + const Problem& p = static_cast <const Problem&> (problem); return create (p); } GraphSteeringMethodPtr_t GraphSteeringMethod::create - (const ProblemPtr_t& problem) + (const Problem& problem) { GraphSteeringMethod* ptr = new GraphSteeringMethod (problem); GraphSteeringMethodPtr_t shPtr (ptr); @@ -53,7 +52,7 @@ namespace hpp { return shPtr; } - GraphSteeringMethod::GraphSteeringMethod (const ProblemPtr_t& problem) : + GraphSteeringMethod::GraphSteeringMethod (const Problem& problem) : SteeringMethod (problem), problem_ (problem), weak_ () { } @@ -66,7 +65,7 @@ namespace hpp { PathPtr_t GraphSteeringMethod::impl_compute (ConfigurationIn_t q1, ConfigurationIn_t q2) const { graph::Edges_t possibleEdges; - graph::Graph& graph = *problem_->constraintGraph (); + const graph::Graph& graph = *problem_.constraintGraph (); try { possibleEdges = graph.getEdges (graph.getState (q1), graph.getState (q2)); diff --git a/src/problem.cc b/src/problem.cc index 1f50bd35..4658f6bb 100644 --- a/src/problem.cc +++ b/src/problem.cc @@ -27,7 +27,7 @@ namespace hpp { Problem::Problem (DevicePtr_t robot) : Parent (robot), graph_() { - Parent::steeringMethod (GraphSteeringMethod::create (this)); + Parent::steeringMethod (GraphSteeringMethod::create (*this)); distance (WeighedDistance::create (robot, graph_)); setPathValidationFactory(core::DiscretizedCollisionChecking::create, 0.05); -- GitLab