From de15cf2892cdc42b0b270051c1de3680c56521d4 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Fri, 5 Jan 2018 15:28:41 +0100
Subject: [PATCH] Split GraphSteeringMethod in two class

---
 include/hpp/manipulation/fwd.hh               |  2 +
 .../hpp/manipulation/graph-steering-method.hh | 48 ++++++++++++-------
 include/hpp/manipulation/problem.hh           |  2 +-
 src/graph-steering-method.cc                  | 18 +++++--
 src/problem.cc                                |  4 +-
 5 files changed, 51 insertions(+), 23 deletions(-)

diff --git a/include/hpp/manipulation/fwd.hh b/include/hpp/manipulation/fwd.hh
index e35e1055..5b846cb5 100644
--- a/include/hpp/manipulation/fwd.hh
+++ b/include/hpp/manipulation/fwd.hh
@@ -86,7 +86,9 @@ namespace hpp {
     typedef boost::shared_ptr < SymbolicPlanner > SymbolicPlannerPtr_t;
     HPP_PREDEF_CLASS (GraphPathValidation);
     typedef boost::shared_ptr < GraphPathValidation > GraphPathValidationPtr_t;
+    HPP_PREDEF_CLASS (SteeringMethod);
     HPP_PREDEF_CLASS (GraphSteeringMethod);
+    typedef boost::shared_ptr < SteeringMethod > SteeringMethodPtr_t;
     typedef boost::shared_ptr < GraphSteeringMethod > GraphSteeringMethodPtr_t;
     typedef core::PathOptimizer PathOptimizer;
     typedef core::PathOptimizerPtr_t PathOptimizerPtr_t;
diff --git a/include/hpp/manipulation/graph-steering-method.hh b/include/hpp/manipulation/graph-steering-method.hh
index 42d96c6b..d21d7a46 100644
--- a/include/hpp/manipulation/graph-steering-method.hh
+++ b/include/hpp/manipulation/graph-steering-method.hh
@@ -27,11 +27,41 @@
 
 namespace hpp {
   namespace manipulation {
-    using core::SteeringMethod;
     using core::PathPtr_t;
     /// \addtogroup steering_method
     /// \{
 
+    class HPP_MANIPULATION_DLLAPI SteeringMethod : public core::SteeringMethod
+    {
+      public:
+        const core::SteeringMethodPtr_t& innerSteeringMethod () const
+        {
+          return steeringMethod_;
+        }
+
+        void innerSteeringMethod (const core::SteeringMethodPtr_t& sm)
+        {
+          steeringMethod_ = sm;
+        }
+
+      protected:
+        /// Constructor
+        SteeringMethod (const Problem& problem);
+
+        /// Copy constructor
+        SteeringMethod (const SteeringMethod& other);
+
+        void init (SteeringMethodWkPtr_t weak)
+        {
+          core::SteeringMethod::init (weak);
+        }
+
+        /// A pointer to the manipulation problem
+        const Problem& problem_;
+        /// The encapsulated steering method
+        core::SteeringMethodPtr_t steeringMethod_;
+    };
+
     class HPP_MANIPULATION_DLLAPI GraphSteeringMethod : public SteeringMethod
     {
       typedef core::SteeringMethodBuilder_t SteeringMethodBuilder_t;
@@ -59,16 +89,6 @@ namespace hpp {
           return createCopy (weak_.lock ());
         }
 
-        const core::SteeringMethodPtr_t& innerSteeringMethod () const
-        {
-          return steeringMethod_;
-        }
-
-        void innerSteeringMethod (const core::SteeringMethodPtr_t& sm)
-        {
-          steeringMethod_ = sm;
-        }
-
       protected:
         /// Constructor
         GraphSteeringMethod (const Problem& problem);
@@ -80,17 +100,13 @@ namespace hpp {
 
         void init (GraphSteeringMethodWkPtr_t weak)
         {
-          core::SteeringMethod::init (weak);
+          SteeringMethod::init (weak);
           weak_ = weak;
         }
 
       private:
-        /// A pointer to the problem
-        const Problem& problem_;
         /// Weak pointer to itself
         GraphSteeringMethodWkPtr_t weak_;
-        /// The encapsulated steering method
-        core::SteeringMethodPtr_t steeringMethod_;
     };
 
     template <typename T>
diff --git a/include/hpp/manipulation/problem.hh b/include/hpp/manipulation/problem.hh
index 6b4b05ef..c7c318b5 100644
--- a/include/hpp/manipulation/problem.hh
+++ b/include/hpp/manipulation/problem.hh
@@ -64,7 +64,7 @@ namespace hpp {
         void pathValidation (const PathValidationPtr_t& pathValidation);
 
         /// Get the steering method as a GraphSteeringMethod
-        GraphSteeringMethodPtr_t steeringMethod () const;
+        SteeringMethodPtr_t steeringMethod () const;
 
         /// Build a new path validation
         /// \note Current obstacles are added to the created object.
diff --git a/src/graph-steering-method.cc b/src/graph-steering-method.cc
index f6f11bea..44638881 100644
--- a/src/graph-steering-method.cc
+++ b/src/graph-steering-method.cc
@@ -27,6 +27,18 @@
 
 namespace hpp {
   namespace manipulation {
+    SteeringMethod::SteeringMethod (const Problem& problem) :
+      core::SteeringMethod (problem), problem_ (problem),
+      steeringMethod_ (core::SteeringMethodStraight::create (problem))
+    {
+    }
+
+    SteeringMethod::SteeringMethod (const SteeringMethod& other):
+      core::SteeringMethod (other), problem_ (other.problem_), steeringMethod_
+      (other.steeringMethod_)
+    {
+    }
+
     GraphSteeringMethodPtr_t GraphSteeringMethod::create
       (const core::Problem& problem)
     {
@@ -54,14 +66,12 @@ namespace hpp {
     }
 
     GraphSteeringMethod::GraphSteeringMethod (const Problem& problem) :
-      SteeringMethod (problem), problem_ (problem), weak_ (),
-      steeringMethod_ (core::SteeringMethodStraight::create (problem))
+      SteeringMethod (problem), weak_ ()
     {
     }
 
     GraphSteeringMethod::GraphSteeringMethod (const GraphSteeringMethod& other):
-      SteeringMethod (other), problem_ (other.problem_), steeringMethod_
-      (other.steeringMethod_)
+      SteeringMethod (other)
     {
     }
 
diff --git a/src/problem.cc b/src/problem.cc
index 4658f6bb..78a1b72c 100644
--- a/src/problem.cc
+++ b/src/problem.cc
@@ -68,9 +68,9 @@ namespace hpp {
       return pv;
     }
 
-    GraphSteeringMethodPtr_t Problem::steeringMethod () const
+    SteeringMethodPtr_t Problem::steeringMethod () const
     {
-      return HPP_DYNAMIC_PTR_CAST (GraphSteeringMethod,
+      return HPP_DYNAMIC_PTR_CAST (SteeringMethod,
           Parent::steeringMethod());
     }
   } // namespace manipulation
-- 
GitLab