From 4e19b066d27b90355657688f67b6e2f208390a82 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 17 Mar 2013 12:32:43 -0700 Subject: gras: property implementation in lib --- include/gras/detail/block.hpp | 8 ++++---- include/gras/detail/property.hpp | 25 ++++++++----------------- 2 files changed, 12 insertions(+), 21 deletions(-) (limited to 'include/gras/detail') diff --git a/include/gras/detail/block.hpp b/include/gras/detail/block.hpp index 483b2bf..a8bc2b1 100644 --- a/include/gras/detail/block.hpp +++ b/include/gras/detail/block.hpp @@ -13,21 +13,21 @@ GRAS_FORCE_INLINE void Block::register_property( void(ClassType::*set)(const ValueType &) ) { - boost::shared_ptr pr; + PropertyRegistrySptr pr; pr.reset(new PropertyRegistryImpl(this, get, set)); - this->property_interface_register(key, pr); + this->_register_property(key, pr); } template GRAS_FORCE_INLINE void Block::set_property(const std::string &key, const ValueType &value) { - return this->property_interface_set(key, PMC_M(value)); + return this->_set_property(key, PMC_M(value)); } template GRAS_FORCE_INLINE ValueType Block::get_property(const std::string &key) { - return this->property_interface_get(key).as(); + return this->_get_property(key).as(); } } //namespace gras diff --git a/include/gras/detail/property.hpp b/include/gras/detail/property.hpp index 467fb70..fd13025 100644 --- a/include/gras/detail/property.hpp +++ b/include/gras/detail/property.hpp @@ -3,19 +3,23 @@ #ifndef INCLUDED_GRAS_DETAIL_PROPERTY_HPP #define INCLUDED_GRAS_DETAIL_PROPERTY_HPP +#include #include +#include namespace gras { -struct PropertyRegistry +struct GRAS_API PropertyRegistry { - PropertyRegistry(void){} - ~PropertyRegistry(void){} + PropertyRegistry(void); + virtual ~PropertyRegistry(void); virtual void set(const PMCC &) = 0; virtual PMCC get(void) = 0; }; +typedef boost::shared_ptr PropertyRegistrySptr; + template struct PropertyRegistryImpl : PropertyRegistry { @@ -28,7 +32,7 @@ struct PropertyRegistryImpl : PropertyRegistry _getter(getter), _setter(setter) {} - ~PropertyRegistryImpl(void){} + virtual ~PropertyRegistryImpl(void){} void set(const PMCC &value) { @@ -45,19 +49,6 @@ struct PropertyRegistryImpl : PropertyRegistry void(ClassType::*_setter)(const ValueType &); }; -struct PropertyInterface -{ - virtual void property_interface_register( - const std::string &key, - boost::shared_ptr pr - ) = 0; - - virtual void property_interface_set(const std::string &key, const PMCC &value) = 0; - - virtual PMCC property_interface_get(const std::string &key) = 0; - -}; - } //namespace gras #endif /*INCLUDED_GRAS_DETAIL_PROPERTY_HPP*/ -- cgit