From f6e6550a11cbc2813042c16cd179a69191c14000 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Tue, 29 Jul 2014 17:16:50 +0200
Subject: [PATCH] Separate declaration and definition of Robot

---
 include/hpp/manipulation/robot.hh | 64 +++++++----------------------
 src/robot.cc                      | 68 ++++++++++++++++++++++++++++---
 2 files changed, 78 insertions(+), 54 deletions(-)

diff --git a/include/hpp/manipulation/robot.hh b/include/hpp/manipulation/robot.hh
index 3643b8fd..db114384 100644
--- a/include/hpp/manipulation/robot.hh
+++ b/include/hpp/manipulation/robot.hh
@@ -20,10 +20,11 @@
 #ifndef HPP_MANIPULATION_ROBOT_HH
 # define HPP_MANIPULATION_ROBOT_HH
 
-# include <hpp/manipulation/handle.hh>
-# include <hpp/manipulation/object.hh>
 # include <hpp/model/device.hh>
 
+# include "hpp/manipulation/fwd.hh"
+# include "hpp/manipulation/config.hh"
+
 namespace hpp {
   namespace manipulation {
     /// Robot holding one or several objects.
@@ -58,68 +59,33 @@ namespace hpp {
 			   vectorIn_t fullVelocity);
 
       /// Get robot manipulating objects
-      const Devices_t& robots () const
-      {
-	return robots_;
-      }
+      const Devices_t& robots () const;
+
       /// Get objects manipulated by the robot
-      const Objects_t& objects () const
-      {
-	return objects_;
-      }
+      const Objects_t& objects () const;
+
       /// Get joint of this corresponding to joint of original object or robot.
-      const JointPtr_t& joint (const JointConstPtr_t& original)
-      {
-	return jointMap_ [original];
-      }
+      const JointPtr_t& joint (const JointConstPtr_t& original);
 
       /// \name Composite robot handles
       /// \{
 
       /// Add a handle
-      void addHandle (const std::string& name, const HandlePtr_t& handle)
-      {
-	handles_ [name] = handle;
-      }
+      void addHandle (const std::string& name, const HandlePtr_t& handle);
+
       /// Return the handle named name
-      const HandlePtr_t& handle (const std::string& name) const
-      {
-	Handles_t::const_iterator it = handles_.find (name);
-	if (it == handles_.end ())
-	  throw std::runtime_error ("no handle with name " + name);
-	return it->second;
-      }
+      const HandlePtr_t& handle (const std::string& name) const;
       /// \}
 
       /// Add a gripper
-      void addGripper (const std::string& name, const GripperPtr_t& gripper)
-      {
-        grippers_ [name] = gripper;
-      }
+      void addGripper (const std::string& name, const GripperPtr_t& gripper);
+
       /// Return the gripper named name
-      const GripperPtr_t& gripper (const std::string& name) const
-      {
-	Grippers_t::const_iterator it = grippers_.find (name);
-	if (it == grippers_.end ())
-	  throw std::runtime_error ("no gripper with name " + name);
-	return it->second;
-      }
+      const GripperPtr_t& gripper (const std::string& name) const;
 
       /// Get Device names in the same order than the compositeRobot has been
       /// build
-      std::vector<std::string> getDeviceNames()
-      {
-        std::vector<std::string> deviceNames;
-        for ( Devices_t::iterator itDevice = robots_.begin() ; itDevice != 
-                robots_.end() ; itDevice++ ) {
-          deviceNames.push_back((*itDevice)->name());
-        }
-        for ( Objects_t::iterator itObject = objects_.begin() ; itObject !=
-                objects_.end() ; itObject++ ) {
-          deviceNames.push_back((*itObject)->name());
-        }
-        return deviceNames;
-      }
+      std::vector<std::string> getDeviceNames();
 
       /// Print object in a stream
       virtual std::ostream& print (std::ostream& os) const;
diff --git a/src/robot.cc b/src/robot.cc
index c42f304c..e06e9ff0 100644
--- a/src/robot.cc
+++ b/src/robot.cc
@@ -18,10 +18,13 @@
 // <http://www.gnu.org/licenses/>.
 
 #include <hpp/util/debug.hh>
-#include <hpp/manipulation/fwd.hh>
-#include <hpp/model/object-factory.hh>
-#include <hpp/manipulation/robot.hh>
 #include <hpp/model/gripper.hh>
+#include <hpp/model/object-factory.hh>
+
+#include "hpp/manipulation/fwd.hh"
+#include "hpp/manipulation/handle.hh"
+#include "hpp/manipulation/object.hh"
+#include "hpp/manipulation/robot.hh"
 
 namespace hpp {
   namespace manipulation {
@@ -29,6 +32,61 @@ namespace hpp {
     typedef std::map <std::string, GripperPtr_t> Grippers_t;
     typedef std::vector<JointPtr_t> JointVector_t;
 
+    const Devices_t& Robot::robots () const
+    {
+      return robots_;
+    }
+
+    const Objects_t& Robot::objects () const
+    {
+      return objects_;
+    }
+
+    const JointPtr_t& Robot::joint (const JointConstPtr_t& original)
+    {
+      return jointMap_ [original];
+    }
+
+    void Robot::addHandle (const std::string& name, const HandlePtr_t& handle)
+    {
+      handles_ [name] = handle;
+    }
+
+    const HandlePtr_t& Robot::handle (const std::string& name) const
+    {
+      Handles_t::const_iterator it = handles_.find (name);
+      if (it == handles_.end ())
+        throw std::runtime_error ("no handle with name " + name);
+      return it->second;
+    }
+
+    void Robot::addGripper (const std::string& name, const GripperPtr_t& gripper)
+    {
+      grippers_ [name] = gripper;
+    }
+
+    const GripperPtr_t& Robot::gripper (const std::string& name) const
+    {
+      Grippers_t::const_iterator it = grippers_.find (name);
+      if (it == grippers_.end ())
+        throw std::runtime_error ("no gripper with name " + name);
+      return it->second;
+    }
+
+    std::vector<std::string> Robot::getDeviceNames()
+    {
+      std::vector<std::string> deviceNames;
+      for ( Devices_t::iterator itDevice = robots_.begin() ; itDevice !=
+          robots_.end() ; itDevice++ ) {
+        deviceNames.push_back((*itDevice)->name());
+      }
+      for ( Objects_t::iterator itObject = objects_.begin() ; itObject !=
+          objects_.end() ; itObject++ ) {
+        deviceNames.push_back((*itObject)->name());
+      }
+      return deviceNames;
+    }
+
     void Robot::copyKinematicChain (const JointPtr_t& parentJoint,
 				    const JointConstPtr_t& joint)
     {
@@ -86,7 +144,7 @@ namespace hpp {
         for (model::JointVector_t::const_iterator itJoint = joints.begin() ;
                itJoint != joints.end() ; itJoint++ ) {
           gripper->addDisabledCollision(jointMap_[*itJoint]);
-        } 	 
+        }
 	addGripper (gripper->name (), gripper);
       }
     }
@@ -200,7 +258,7 @@ namespace hpp {
                                               "," << joint2->name() << ")");
 	      hpp::model::Device::addCollisionPairs (joint1, joint2,
                                                       hpp::model::COLLISION);
-	      hpp::model::Device::addCollisionPairs (joint1, joint2, 
+	      hpp::model::Device::addCollisionPairs (joint1, joint2,
                                                       hpp::model::DISTANCE);
             }
 	  }
-- 
GitLab