From 468d53f7797c63cda2ef9ba765f1066550d19ce4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 17 Mar 2013 17:38:40 -0700 Subject: gras: work on python hooks for props interface --- lib/block_props.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lib/block_props.cpp') 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 **********************************************************************/ -- cgit