summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gras/block.hpp98
-rw-r--r--include/gras/detail/block.hpp91
-rw-r--r--include/gras/detail/callable.hpp2
-rw-r--r--include/gras/element.hpp3
4 files changed, 4 insertions, 190 deletions
diff --git a/include/gras/block.hpp b/include/gras/block.hpp
index f2f1b2b..644a73c 100644
--- a/include/gras/block.hpp
+++ b/include/gras/block.hpp
@@ -162,97 +162,6 @@ struct GRAS_API Block : Element
void post_input_msg(const size_t which_input, const ValueType &value);
/*******************************************************************
- * The property interface:
- * Provides polymorphic, thread-safe access to block properties.
- ******************************************************************/
-
- /*!
- * Register property getter method into the property interface.
- * Call register_getter() from the contructor of the block.
- *
- * Example register usage:
- * this->register_getter("foo", &MyBlock::get_foo);
- *
- * Example method declaration:
- * int get_foo(void);
- *
- * \param key the string to identify this property
- * \param get the class method to get the property
- */
- template <typename ClassType, typename ValueType>
- void register_getter(
- const std::string &key,
- ValueType(ClassType::*get)(void)
- );
-
- /*!
- * Register property setter method into the property interface.
- * Call register_setter() from the contructor of the block.
- *
- * Example register usage:
- * this->register_setter("foo", &MyBlock::set_foo);
- *
- * Example method declaration:
- * void set_foo(const int &new_foo);
- *
- * \param key the string to identify this property
- * \param set the class method to set the property
- */
- template <typename ClassType, typename ValueType>
- void register_setter(
- const std::string &key,
- void(ClassType::*set)(const ValueType &)
- );
-
- /*!
- * Set the value of a registered property.
- *
- * This call is synchronous and will not return until
- * the block has actually called the registered set operation.
- *
- * Note: the user must be careful to only use a value
- * that is of the exact type associated with this property.
- * Otherwise, set_property with throw a type error.
- *
- * Examples with explicit argument types:
- * my_block->set<size_t>("foo", 42);
- * my_block->set("foo", size_t(42));
- *
- * \param key the string to identify this property
- * \param value the new value to set to this property
- */
- template <typename ValueType>
- void set(const std::string &key, const ValueType &value);
-
- /*!
- * Get the value of a registered property with reference semantics.
- *
- * Note: the user must be careful to only use a value
- * that is of the exact type associated with this property.
- * Otherwise, get_property with throw a type error.
- *
- * Example getting property with reference semantics:
- * size_t foo; my_block->get("foo", foo);
- *
- * \param key the string to identify this property
- * \param value a reference to set to the result
- */
- template <typename ValueType>
- void get(const std::string &key, ValueType &value);
-
- /*!
- * Get the value of a registered property with return semantics.
- *
- * Example getting property with return value semantics:
- * const size_t foo = my_block->get<size_t>("foo");
- *
- * \param key the string to identify this property
- * \return the value of this property
- */
- template <typename ValueType>
- ValueType get(const std::string &key);
-
- /*******************************************************************
* Work related routines and fail states
******************************************************************/
@@ -430,11 +339,8 @@ struct GRAS_API Block : Element
/*******************************************************************
* private implementation guts for overloads and template support
******************************************************************/
- virtual PMCC _handle_prop_access(const std::string &, const PMCC &, const bool);
- void _register_getter(const std::string &, void *);
- void _register_setter(const std::string &, void *);
- virtual void _set_property(const std::string &, const PMCC &);
- virtual PMCC _get_property(const std::string &);
+ PMCC _handle_call(const std::string &, const PMCC *);
+ virtual PMCC _handle_call_ts(const std::string &, const PMCC *);
void _post_output_msg(const size_t which_output, const PMCC &msg);
void _post_input_msg(const size_t which_input, const PMCC &msg);
};
diff --git a/include/gras/detail/block.hpp b/include/gras/detail/block.hpp
index 9dccb22..3f94e54 100644
--- a/include/gras/detail/block.hpp
+++ b/include/gras/detail/block.hpp
@@ -3,100 +3,9 @@
#ifndef INCLUDED_GRAS_DETAIL_BLOCK_HPP
#define INCLUDED_GRAS_DETAIL_BLOCK_HPP
-#include <typeinfo>
-
namespace gras
{
-struct GRAS_API PropertyRegistry
-{
- PropertyRegistry(void);
- virtual ~PropertyRegistry(void);
- virtual void set(const PMCC &) = 0;
- virtual PMCC get(void) = 0;
- virtual const std::type_info &type(void) const = 0;
-};
-
-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.safe_as<ValueType>());
- }
-
- PMCC get(void)
- {
- return PMC_M((_my_class->*_getter)());
- }
-
- const std::type_info &type(void) const
- {
- return typeid(ValueType);
- }
-
-private:
- ClassType *_my_class;
- ValueType(ClassType::*_getter)(void);
- void(ClassType::*_setter)(const ValueType &);
-};
-
-/*!
- * The following functions implement the templated methods in Block
- */
-
-template <typename ClassType, typename ValueType>
-inline void Block::register_getter(
- const std::string &key,
- ValueType(ClassType::*get)(void)
-)
-{
- ClassType *obj = dynamic_cast<ClassType *>(this);
- void *pr = new PropertyRegistryImpl<ClassType, ValueType>(obj, get, NULL);
- this->_register_getter(key, pr);
-}
-
-template <typename ClassType, typename ValueType>
-inline void Block::register_setter(
- const std::string &key,
- void(ClassType::*set)(const ValueType &)
-)
-{
- ClassType *obj = dynamic_cast<ClassType *>(this);
- void *pr = new PropertyRegistryImpl<ClassType, ValueType>(obj, NULL, set);
- this->_register_setter(key, pr);
-}
-
-template <typename ValueType>
-inline void Block::set(const std::string &key, const ValueType &value)
-{
- this->_set_property(key, PMC_M(value));
-}
-
-template <typename ValueType>
-inline void Block::get(const std::string &key, ValueType &value)
-{
- value = this->_get_property(key).safe_as<ValueType>();
-}
-
-template <typename ValueType>
-inline ValueType Block::get(const std::string &key)
-{
- return this->_get_property(key).safe_as<ValueType>();
-}
-
template <typename ValueType>
inline void Block::post_output_msg(const size_t i, const ValueType &value)
{
diff --git a/include/gras/detail/callable.hpp b/include/gras/detail/callable.hpp
index b3f0d00..3f5252d 100644
--- a/include/gras/detail/callable.hpp
+++ b/include/gras/detail/callable.hpp
@@ -3,8 +3,6 @@
#ifndef INCLUDED_GRAS_DETAIL_CALLABLE_HPP
#define INCLUDED_GRAS_DETAIL_CALLABLE_HPP
-#include <typeinfo>
-
namespace gras
{
diff --git a/include/gras/element.hpp b/include/gras/element.hpp
index 47fbae6..9b46d76 100644
--- a/include/gras/element.hpp
+++ b/include/gras/element.hpp
@@ -9,6 +9,7 @@
#endif //_MSC_VER
#include <gras/gras.hpp>
+#include <gras/callable.hpp>
#include <gras/weak_container.hpp>
#include <boost/shared_ptr.hpp>
@@ -18,7 +19,7 @@ namespace gras
/*!
* Element is a base class for all topological elements.
*/
-struct GRAS_API Element : boost::shared_ptr<ElementImpl>
+struct GRAS_API Element : Callable, boost::shared_ptr<ElementImpl>
{
//! Create an empty element
Element(void);