summaryrefslogtreecommitdiff
path: root/include/gras/detail
diff options
context:
space:
mode:
authorJosh Blum2013-03-21 00:00:06 -0700
committerJosh Blum2013-03-21 00:00:06 -0700
commit5485d42efba261c8879d1208c31d9cd5d18c303d (patch)
treec89d955ef6e86d471eb47989293643136421330f /include/gras/detail
parentf954bb2d93b083ff911a014711b1ea079060faf7 (diff)
downloadsandhi-5485d42efba261c8879d1208c31d9cd5d18c303d.tar.gz
sandhi-5485d42efba261c8879d1208c31d9cd5d18c303d.tar.bz2
sandhi-5485d42efba261c8879d1208c31d9cd5d18c303d.zip
gras: combine block property headers
Diffstat (limited to 'include/gras/detail')
-rw-r--r--include/gras/detail/block.hpp43
-rw-r--r--include/gras/detail/property.hpp56
2 files changed, 42 insertions, 57 deletions
diff --git a/include/gras/detail/block.hpp b/include/gras/detail/block.hpp
index 588c3cc..2a48080 100644
--- a/include/gras/detail/block.hpp
+++ b/include/gras/detail/block.hpp
@@ -6,6 +6,47 @@
namespace gras
{
+struct GRAS_API PropertyRegistry
+{
+ 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>
+class PropertyRegistryImpl : public PropertyRegistry
+{
+public:
+ PropertyRegistryImpl(
+ ClassType *my_class,
+ ValueType(ClassType::*getter)(void),
+ void(ClassType::*setter)(const ValueType &)
+ ):
+ _my_class(my_class),
+ _getter(getter),
+ _setter(setter)
+ {}
+ virtual ~PropertyRegistryImpl(void){}
+
+ void set(const PMCC &value)
+ {
+ (_my_class->*_setter)(value.as<ValueType>());
+ }
+
+ PMCC get(void)
+ {
+ return PMC_M((_my_class->*_getter)());
+ }
+
+private:
+ ClassType *_my_class;
+ ValueType(ClassType::*_getter)(void);
+ void(ClassType::*_setter)(const ValueType &);
+};
+
/*!
* The following functions implement the templated methods in Block
*/
@@ -19,7 +60,7 @@ inline void Block::register_property(
{
PropertyRegistrySptr pr;
pr.reset(new PropertyRegistryImpl<ClassType, ValueType>((ClassType *)this, get, set));
- this->_register_property(key, pr);
+ this->_register_property(key, PMC_M(pr));
}
template <typename ValueType>
diff --git a/include/gras/detail/property.hpp b/include/gras/detail/property.hpp
deleted file mode 100644
index 2fcdca0..0000000
--- a/include/gras/detail/property.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
-
-#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 GRAS_API PropertyRegistry
-{
- 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>
-class PropertyRegistryImpl : public PropertyRegistry
-{
-public:
- PropertyRegistryImpl(
- ClassType *my_class,
- ValueType(ClassType::*getter)(void),
- void(ClassType::*setter)(const ValueType &)
- ):
- _my_class(my_class),
- _getter(getter),
- _setter(setter)
- {}
- virtual ~PropertyRegistryImpl(void){}
-
- void set(const PMCC &value)
- {
- (_my_class->*_setter)(value.as<ValueType>());
- }
-
- PMCC get(void)
- {
- return PMC_M((_my_class->*_getter)());
- }
-
-private:
- ClassType *_my_class;
- ValueType(ClassType::*_getter)(void);
- void(ClassType::*_setter)(const ValueType &);
-};
-
-} //namespace gras
-
-#endif /*INCLUDED_GRAS_DETAIL_PROPERTY_HPP*/