From ddb7d5bad5a806cb14e6c9970cc253453c32a320 Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Mon, 31 Aug 2015 08:17:20 +0200
Subject: [PATCH] In Device::operator<<, write Gripper and Handle instead of
 their pointers.

---
 include/hpp/manipulation/container.hh | 10 ++++++++++
 include/hpp/manipulation/device.hh    | 12 +-----------
 src/device.cc                         | 14 ++++++++++++++
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/include/hpp/manipulation/container.hh b/include/hpp/manipulation/container.hh
index d9d8b5f..a68751a 100644
--- a/include/hpp/manipulation/container.hh
+++ b/include/hpp/manipulation/container.hh
@@ -71,6 +71,16 @@ namespace hpp {
           return os;
         }
 
+        /// Print object in a stream
+        std::ostream& printPointer (std::ostream& os) const
+        {
+          for (typename ElementMap_t::const_iterator it = map_.begin ();
+              it != map_.end (); ++it) {
+            os << it->first << " : " << *(it->second) << std::endl;
+          }
+          return os;
+        }
+
       protected:
         /// Constructor
         Container () : map_ ()
diff --git a/include/hpp/manipulation/device.hh b/include/hpp/manipulation/device.hh
index 3617237..e184891 100644
--- a/include/hpp/manipulation/device.hh
+++ b/include/hpp/manipulation/device.hh
@@ -52,17 +52,7 @@ namespace hpp {
         }
 
         /// Print object in a stream
-        virtual std::ostream& print (std::ostream& os) const
-        {
-          Parent_t::print (os);
-          // print handles
-          os << "Handles:" << std::endl;
-          Container <HandlePtr_t>::print (os);
-          // print grippers
-          os << "Grippers:" << std::endl;
-          Container <model::GripperPtr_t>::print (os);
-          return os;
-        }
+        virtual std::ostream& print (std::ostream& os) const;
 
         /// \name Accessors to container elements
         /// Contained elements are of type model::Gripper, Handle and
diff --git a/src/device.cc b/src/device.cc
index 9d73727..392d89f 100644
--- a/src/device.cc
+++ b/src/device.cc
@@ -17,7 +17,9 @@
 // hpp-manipulation. If not, see
 // <http://www.gnu.org/licenses/>.
 
+#include <hpp/model/gripper.hh>
 #include <hpp/manipulation/device.hh>
+#include <hpp/manipulation/handle.hh>
 
 #include <hpp/model/joint.hh>
 
@@ -49,5 +51,17 @@ namespace hpp {
           }
           jointCache_.clear ();
         }
+    std::ostream& Device::print (std::ostream& os) const
+    {
+      Parent_t::print (os);
+      // print handles
+      os << "Handles:" << std::endl;
+      Container <HandlePtr_t>::printPointer (os);
+      // print grippers
+      os << "Grippers:" << std::endl;
+      Container <model::GripperPtr_t>::printPointer (os);
+      return os;
+    }
+
   } // namespace manipulation
 } // namespace hpp
-- 
GitLab