diff --git a/modules/base/pymod/export_generic_property.cc b/modules/base/pymod/export_generic_property.cc index f36a12d068d85c476cfec3e12f15c24b8ef76b2d..b5fab8c7a1291ed4b56715a077e28ca7dac59831 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 ef13e3490ac3b298fc0c50f1f192cb620672c4fd..ff02641c5a1e436a590aa8f23e0529f7dda88031 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 0b336e1ef8daed75e6084ef2d21d7937fa5ecae8..7c0ba516ae6068b079028e940aa5708019cfbf5e 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));