summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJosh Blum2013-03-17 12:32:43 -0700
committerJosh Blum2013-03-17 12:32:43 -0700
commit4e19b066d27b90355657688f67b6e2f208390a82 (patch)
treef72809037a62f883f1a60acddb3115e376da889a /include
parentb142e0e75f8ab4e7b2bb70c3fc71b61fd5f71651 (diff)
downloadsandhi-4e19b066d27b90355657688f67b6e2f208390a82.tar.gz
sandhi-4e19b066d27b90355657688f67b6e2f208390a82.tar.bz2
sandhi-4e19b066d27b90355657688f67b6e2f208390a82.zip
gras: property implementation in lib
Diffstat (limited to 'include')
-rw-r--r--include/gras/block.hpp9
-rw-r--r--include/gras/detail/block.hpp8
-rw-r--r--include/gras/detail/property.hpp25
3 files changed, 20 insertions, 22 deletions
diff --git a/include/gras/block.hpp b/include/gras/block.hpp
index d33457b..d3e9848 100644
--- a/include/gras/block.hpp
+++ b/include/gras/block.hpp
@@ -106,7 +106,7 @@ struct GRAS_API OutputPortConfig
size_t maximum_items;
};
-struct GRAS_API Block : Element, PropertyInterface
+struct GRAS_API Block : Element
{
//! Contruct an empty/null block
@@ -458,6 +458,13 @@ struct GRAS_API Block : Element, PropertyInterface
const SBufferConfig &config
);
+ /*******************************************************************
+ * private implementation guts for template support
+ ******************************************************************/
+ void _register_property(const std::string &, PropertyRegistrySptr);
+ void _set_property(const std::string &, const PMCC &);
+ PMCC _get_property(const std::string &);
+
};
} //namespace gras
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<PropertyRegistry> pr;
+ PropertyRegistrySptr pr;
pr.reset(new PropertyRegistryImpl<ClassType, ValueType>(this, get, set));
- this->property_interface_register(key, pr);
+ this->_register_property(key, pr);
}
template <typename ValueType>
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 <typename ValueType>
GRAS_FORCE_INLINE ValueType Block::get_property(const std::string &key)
{
- return this->property_interface_get(key).as<ValueType>();
+ return this->_get_property(key).as<ValueType>();
}
} //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 <gras/gras.hpp>
#include <PMC/PMC.hpp>
+#include <boost/shared_ptr.hpp>
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<PropertyRegistry> PropertyRegistrySptr;
+
template <typename ClassType, typename ValueType>
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<PropertyRegistry> 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*/