From 2542b861e3f9ea175d51df3b8ab9e18c12573745 Mon Sep 17 00:00:00 2001
From: Florent Lamiraux <florent@laas.fr>
Date: Wed, 14 Mar 2012 10:09:41 +0100
Subject: [PATCH] Document class RosExport and implement method list.

---
 src/ros_export.cpp | 44 +++++++++++++++++++++++++++++++++++++++-----
 src/ros_export.hh  |  2 +-
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/src/ros_export.cpp b/src/ros_export.cpp
index 0336ff4..6a8bffa 100644
--- a/src/ros_export.cpp
+++ b/src/ros_export.cpp
@@ -49,8 +49,7 @@ namespace dynamicgraph
       {
 	RosExport& entity =
 	  static_cast<RosExport&> (owner ());
-	entity.list ();
-	return Value ();
+	return Value (entity.list ());
       }
 
       Add::Add
@@ -122,16 +121,45 @@ namespace dynamicgraph
       nh_ (rosInit (true)),
       bindedSignal_ ()
   {
-    std::string docstring;
+    std::string docstring =
+      "\n"
+      "  Add a signal reading data from a ROS topic\n"
+      "\n"
+      "  Input:\n"
+      "    - type: string among ['double', 'matrix', 'vector', 'vector3',\n"
+      "                          'vector3Stamped', 'matrixHomo', 'matrixHomoStamped',\n"
+      "                          'twist', 'twistStamped'],\n"
+      "    - signal: the signal name in dynamic-graph,\n"
+      "    - topic:  the topic name in ROS.\n"
+      "\n";
     addCommand ("add",
 		new command::rosExport::Add
 		(*this, docstring));
+    docstring =
+      "\n"
+      "  Remove a signal reading data from a ROS topic\n"
+      "\n"
+      "  Input:\n"
+      "    - name of the signal to remove (see method list for the list of signals).\n"
+      "\n";
     addCommand ("rm",
 		new command::rosExport::Rm
 		(*this, docstring));
+    docstring =
+      "\n"
+      "  Remove all signals reading data from a ROS topic\n"
+      "\n"
+      "  No input:\n"
+      "\n";
     addCommand ("clear",
 		new command::rosExport::Clear
 		(*this, docstring));
+    docstring =
+      "\n"
+      "  List signals reading data from a ROS topic\n"
+      "\n"
+      "  No input:\n"
+      "\n";
     addCommand ("list",
 		new command::rosExport::List
 		(*this, docstring));
@@ -150,9 +178,15 @@ namespace dynamicgraph
     bindedSignal_.erase (signal);
   }
 
-  void RosExport::list ()
+  std::string RosExport::list ()
   {
-    std::cout << CLASS_NAME << std::endl;
+    std::string result("[");
+    for (std::map<std::string, bindedSignal_t>::const_iterator it =
+	   bindedSignal_.begin (); it != bindedSignal_.end (); it++) {
+      result += "'" + it->first + "',";
+    }
+    result += "]";
+    return result;
   }
 
   void RosExport::clear ()
diff --git a/src/ros_export.hh b/src/ros_export.hh
index 564ee64..52bb621 100644
--- a/src/ros_export.hh
+++ b/src/ros_export.hh
@@ -69,7 +69,7 @@ namespace dynamicgraph
 
     void add (const std::string& signal, const std::string& topic);
     void rm (const std::string& signal);
-    void list ();
+    std::string list ();
     void clear ();
 
     template <typename T>
-- 
GitLab