From e708cb1fd8979c5f9ddc57420f6bc8bcece340cb Mon Sep 17 00:00:00 2001
From: Tobias Schmidt <tobias.schmidt@unibas.ch>
Date: Fri, 14 Jan 2011 14:46:49 +0100
Subject: [PATCH] return list of all generic properties

---
 .../src/export_helper/generic_property_def.hh |  4 ++-
 modules/base/src/generic_property.hh          | 32 +++++++++++++++----
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/modules/base/src/export_helper/generic_property_def.hh b/modules/base/src/export_helper/generic_property_def.hh
index 785bcce90..84a486bc3 100644
--- a/modules/base/src/export_helper/generic_property_def.hh
+++ b/modules/base/src/export_helper/generic_property_def.hh
@@ -156,6 +156,7 @@ void const_generic_prop_def(O& bp_class)
     .def("GetIntProp", get_int2)    
     .def("GetStringProp", get_str1)
     .def("GetStringProp", get_str2)    
+    .def("GetPropList",&C::GetPropList)
     .def("GetGenericBoolProperty", &depr_get_bool_a<C>)
     .def("GetGenericBoolProperty", &depr_get_bool_b<C>)
     .def("GetGenericFloatProperty", &depr_get_float_a<C>)
@@ -180,6 +181,7 @@ void generic_prop_def(O& bp_class)
     .def("SetFloatProp", &C::SetFloatProp)
     .def("SetIntProp", &C::SetIntProp)
     .def("SetStringProp", &C::SetStringProp)
+    .def("GetPropList",&C::GetPropList)
     .def("ClearGenericProperties", &depr_clear_props<C>)
     .def("SetGenericIntProperty", &depr_set_int<C>)
     .def("SetGenericFloatProperty", &depr_set_float<C>)
@@ -189,4 +191,4 @@ void generic_prop_def(O& bp_class)
   ;
 }
 
-#endif
\ No newline at end of file
+#endif
diff --git a/modules/base/src/generic_property.hh b/modules/base/src/generic_property.hh
index 12e53932e..8787d95bd 100644
--- a/modules/base/src/generic_property.hh
+++ b/modules/base/src/generic_property.hh
@@ -31,6 +31,7 @@
 #include <exception>
 #include <sstream>
 #include <map>
+#include <vector>
 #include <boost/variant.hpp>
 
 #include <ost/module_config.hh>
@@ -109,6 +110,7 @@ public:
       map_->erase(key);
     }
   }
+
   void Assign(const GenericPropContainerImpl& impl)
   {
     if (impl.map_) {
@@ -130,6 +132,17 @@ public:
     return *map_;
   }
       
+  std::vector<String> GetPropList() const
+  {
+    std::vector<String> prop_list;
+    if (map_) {
+      PropertyMap::const_iterator i;
+      for (i=map_->begin(); i!=map_->end(); ++i) {
+        prop_list.push_back(i->first);
+      }
+    }
+    return prop_list;
+  }
   
 private:
   mutable PropertyMap* map_;
@@ -189,12 +202,13 @@ public:
     rep << this->GetImpl()->GenericProp(key);
     return rep.str();
   }  
-    /// \brief returns String property, raises an exception if it does not exist
-    String GetStringProp(const String& key) const
-    {
-      CheckHandleValidity(*static_cast<const H*>(this));      
-      return this->gp_get<String>(key);
-    }
+
+  /// \brief returns String property, raises an exception if it does not exist
+  String GetStringProp(const String& key) const
+  {
+    CheckHandleValidity(*static_cast<const H*>(this));
+    return this->gp_get<String>(key);
+  }
 
   /// \brief returns floating point property, raises an exception if it does 
   ///     not exist
@@ -279,6 +293,12 @@ public:
     CheckHandleValidity(*static_cast<const H*>(this));    
     return this->GetImpl()->GetPropMap();
   }  
+
+  std::vector<String> GetPropList() const
+  {
+    CheckHandleValidity(*static_cast<const H*>(this));
+    return this->GetImpl()->GetPropList();
+  }
 };
 
 /// \brief base class for the handler classes
-- 
GitLab