summaryrefslogtreecommitdiff
path: root/lib/block_props.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-03-17 17:38:40 -0700
committerJosh Blum2013-03-17 17:38:40 -0700
commit468d53f7797c63cda2ef9ba765f1066550d19ce4 (patch)
tree4008d74ee3138114799e9bf8434f8356e8ad804f /lib/block_props.cpp
parent420f118ed61c52ae00b765b57be83bae910e0a60 (diff)
downloadsandhi-468d53f7797c63cda2ef9ba765f1066550d19ce4.tar.gz
sandhi-468d53f7797c63cda2ef9ba765f1066550d19ce4.tar.bz2
sandhi-468d53f7797c63cda2ef9ba765f1066550d19ce4.zip
gras: work on python hooks for props interface
Diffstat (limited to 'lib/block_props.cpp')
-rw-r--r--lib/block_props.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/block_props.cpp b/lib/block_props.cpp
index 5965085..6bb20e3 100644
--- a/lib/block_props.cpp
+++ b/lib/block_props.cpp
@@ -21,13 +21,10 @@ void BlockActor::handle_prop_access(
reply.set = not message.set;
reply.key = message.key;
- //try to call the property bound method
- PropertyRegistrySptr pr = prop_registry[message.key];
- if (not pr) reply.error = "no property registered for key: " + message.key;
- else try
+ //call into the handler overload to do the property access
+ try
{
- if (message.set) pr->set(message.value);
- else reply.value = pr->get();
+ reply.value = block_ptr->_handle_prop_access(message.key, message.value, message.set);
}
catch (const std::exception &e)
{
@@ -43,6 +40,18 @@ void BlockActor::handle_prop_access(
this->highPrioAck();
}
+PMCC Block::_handle_prop_access(const std::string &key, const PMCC &value, const bool set)
+{
+ PropertyRegistrySptr pr = (*this)->block->prop_registry[key];
+ if (not pr) throw std::invalid_argument("no property registered for key: " + key);
+ if (set)
+ {
+ pr->set(value);
+ return PMCC();
+ }
+ return pr->get();
+}
+
/***********************************************************************
* A special receiver to handle the property access result
**********************************************************************/