From 5635751aaed9668755cbed55e37a937d6bf4af69 Mon Sep 17 00:00:00 2001
From: Niklaus Johner <niklaus.johner@unibas.ch>
Date: Mon, 7 Sep 2015 17:19:41 +0200
Subject: [PATCH] Added Vec3 property.

---
 modules/base/pymod/export_generic_property.cc |  3 +++
 .../src/export_helper/generic_property_def.hh |  8 ++++++--
 modules/base/src/generic_property.hh          | 19 +++++++++++++++++--
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/modules/base/pymod/export_generic_property.cc b/modules/base/pymod/export_generic_property.cc
index f36a12d06..b5fab8c7a 100644
--- a/modules/base/pymod/export_generic_property.cc
+++ b/modules/base/pymod/export_generic_property.cc
@@ -34,6 +34,7 @@ void export_GenericProp()
   int (GenericPropContainer::* get_int2)(const String&, int) const = &GenericPropContainer::GetIntProp;
   bool (GenericPropContainer::* get_bool1)(const String&) const = &GenericPropContainer::GetBoolProp;
   bool (GenericPropContainer::* get_bool2)(const String&, bool) const = &GenericPropContainer::GetBoolProp;
+  geom::Vec3 (GenericPropContainer::* get_vec3)(const String&) const = &GenericPropContainer::GetVec3Prop;
 
   class_<GenericPropContainer, boost::noncopyable>("GenericPropContainer",no_init)
     .def("HasProp",&GenericPropContainer::HasProp)
@@ -49,6 +50,8 @@ void export_GenericProp()
     .def("SetBoolProp",&GenericPropContainer::SetBoolProp)
     .def("GetBoolProp",get_bool1)
     .def("GetBoolProp",get_bool2)
+    .def("SetVec3Prop",&GenericPropContainer::SetVec3Prop)
+    .def("GetVec3Prop",get_vec3)
     .def("ClearProps",&GenericPropContainer::ClearProps)
     .def("GetPropAsString",&GenericPropContainer::GetPropAsString)
     ;
diff --git a/modules/base/src/export_helper/generic_property_def.hh b/modules/base/src/export_helper/generic_property_def.hh
index ef13e3490..ff02641c5 100644
--- a/modules/base/src/export_helper/generic_property_def.hh
+++ b/modules/base/src/export_helper/generic_property_def.hh
@@ -141,7 +141,9 @@ void const_generic_prop_def(O& bp_class)
     
   Real (C::*get_float1)(const String&, Real) const=&C::GetFloatProp;
   Real (C::*get_float2)(const String&) const=&C::GetFloatProp;
-    
+  
+  geom::Vec3 (C::*get_vec3)(const String&) const=&C::GetVec3Prop;
+
   String (C::*get_str1)(const String&, const String&) const=&C::GetStringProp;
   String (C::*get_str2)(const String&) const=&C::GetStringProp;  
   bp_class
@@ -151,7 +153,8 @@ void const_generic_prop_def(O& bp_class)
     .def("GetBoolProp", get_bool1)
     .def("GetBoolProp", get_bool2)        
     .def("GetFloatProp", get_float1)
-    .def("GetFloatProp", get_float2)    
+    .def("GetFloatProp", get_float2) 
+    .def("GetVec3Prop", get_vec3)    
     .def("GetIntProp", get_int1)
     .def("GetIntProp", get_int2)    
     .def("GetStringProp", get_str1)
@@ -179,6 +182,7 @@ void generic_prop_def(O& bp_class)
     .def("ClearProps",  &C::ClearProps)
     .def("GetPropAsString", &C::GetPropAsString)
     .def("SetFloatProp", &C::SetFloatProp)
+    .def("SetVec3Prop", &C::SetVec3Prop)
     .def("SetIntProp", &C::SetIntProp)
     .def("SetStringProp", &C::SetStringProp)
     .def("GetPropList",&C::GetPropList)
diff --git a/modules/base/src/generic_property.hh b/modules/base/src/generic_property.hh
index 0b336e1ef..7c0ba516a 100644
--- a/modules/base/src/generic_property.hh
+++ b/modules/base/src/generic_property.hh
@@ -36,6 +36,7 @@
 #include <ost/module_config.hh>
 #include <ost/invalid_handle.hh>
 #include <ost/message.hh>
+#include <ost/geom/vec3.hh>
 
 namespace ost {
 
@@ -45,8 +46,8 @@ struct  DLLEXPORT GenericPropError: public Error
     Error(m)
   {}
 };
-  
-typedef boost::variant<String, Real, int, bool> GenericPropValue;
+
+typedef boost::variant<String, Real, int, bool, geom::Vec3> GenericPropValue;
 
 ///  \brief base class for the implementation
 class  TEMPLATE_EXPORT GenericPropContainerImpl
@@ -256,6 +257,13 @@ public:
     return this->gp_get<bool>(key);
   }
 
+  /// \brief returns Vec3 property, raises an exception if it does not exist
+  geom::Vec3 GetVec3Prop(const String& key) const
+  {
+    CheckHandleValidity(*static_cast<const H*>(this));    
+    return this->gp_get<geom::Vec3>(key);
+  }
+
   /// \brief returns String property, or the given default if it does not exist
   String GetStringProp(const String& key, const String& def) const
   {
@@ -364,6 +372,13 @@ public:
     this->GetImpl()->GenericProp(key)=value;
   }
   
+  /// \ brief sets Vec3 property
+  void SetVec3Prop(const String& key, geom::Vec3 value)
+  {
+    CheckHandleValidity(*static_cast<const H*>(this));    
+    this->GetImpl()->GenericProp(key)=value;
+  } 
+
   void RemoveProp(const String& key)
   {
     CheckHandleValidity(*static_cast<const H*>(this));
-- 
GitLab