Skip to content
Snippets Groups Projects
Commit 5635751a authored by BIOPZ-Johner Niklaus's avatar BIOPZ-Johner Niklaus
Browse files

Added Vec3 property.

parent 220c1327
Branches
Tags
No related merge requests found
......@@ -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)
;
......
......@@ -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)
......
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment