diff options
author | Josh Blum | 2013-07-04 19:46:58 -0700 |
---|---|---|
committer | Josh Blum | 2013-07-04 19:46:58 -0700 |
commit | 1298bcd1e421ccfefafa78c6d33760818902f399 (patch) | |
tree | e4c57bbcf98f9e7502850e5ab481ba7b9d4c11fc /lib | |
parent | fbec0c405a1fec4e8ee82d065fdc657cdd333f52 (diff) | |
download | sandhi-1298bcd1e421ccfefafa78c6d33760818902f399.tar.gz sandhi-1298bcd1e421ccfefafa78c6d33760818902f399.tar.bz2 sandhi-1298bcd1e421ccfefafa78c6d33760818902f399.zip |
gras: function registry is more flexible
Diffstat (limited to 'lib')
-rw-r--r-- | lib/block_props.cpp | 15 | ||||
-rw-r--r-- | lib/gras_impl/block_data.hpp | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/block_props.cpp b/lib/block_props.cpp index ae687be..fc4c755 100644 --- a/lib/block_props.cpp +++ b/lib/block_props.cpp @@ -5,6 +5,9 @@ using namespace gras; +FunctionRegistry::FunctionRegistry(void){} +FunctionRegistry::~FunctionRegistry(void){} + PropertyRegistry::PropertyRegistry(void){} PropertyRegistry::~PropertyRegistry(void){} @@ -113,3 +116,15 @@ PMCC Block::_get_property(const std::string &key) { return prop_access_dispatcher((*this)->block_actor, key, PMCC(), false); } + + +void Block::_register_function(const std::string &key, void *fr) +{ + (*this)->block_data->function_registry[key].reset(reinterpret_cast<FunctionRegistry *>(fr)); +} + +PMCC Block::_handle_function_access(const std::string &key, const std::vector<PMCC> &args) +{ + //TODO this is testing -- needs to call actor instead + return (*this)->block_data->function_registry[key]->call(args); +} diff --git a/lib/gras_impl/block_data.hpp b/lib/gras_impl/block_data.hpp index cbc657e..664ee5a 100644 --- a/lib/gras_impl/block_data.hpp +++ b/lib/gras_impl/block_data.hpp @@ -18,6 +18,7 @@ namespace gras { +typedef boost::shared_ptr<FunctionRegistry> FunctionRegistrySptr; typedef boost::shared_ptr<PropertyRegistry> PropertyRegistrySptr; struct PropertyRegistryPair { @@ -82,6 +83,7 @@ struct BlockData //property stuff std::map<std::string, PropertyRegistryPair> property_registry; + std::map<std::string, FunctionRegistrySptr> function_registry; BlockStats stats; }; |