summaryrefslogtreecommitdiff
path: root/lib/block_props.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-03-22 01:54:16 -0700
committerJosh Blum2013-03-22 01:54:16 -0700
commit9ea77e78ade12ed5402ed9f3df1f10d9d4d27559 (patch)
tree7355daec02ae124dfd89b821bd21723239f0f03a /lib/block_props.cpp
parenta54708334425472d277e77c394688bab4cac607a (diff)
downloadsandhi-9ea77e78ade12ed5402ed9f3df1f10d9d4d27559.tar.gz
sandhi-9ea77e78ade12ed5402ed9f3df1f10d9d4d27559.tar.bz2
sandhi-9ea77e78ade12ed5402ed9f3df1f10d9d4d27559.zip
gras: we now have the element tree interface
Diffstat (limited to 'lib/block_props.cpp')
-rw-r--r--lib/block_props.cpp47
1 files changed, 1 insertions, 46 deletions
diff --git a/lib/block_props.cpp b/lib/block_props.cpp
index ab8b642..672200b 100644
--- a/lib/block_props.cpp
+++ b/lib/block_props.cpp
@@ -2,8 +2,6 @@
#include "element_impl.hpp"
#include <gras/block.hpp>
-#include <boost/foreach.hpp>
-#include <boost/algorithm/string.hpp>
using namespace gras;
@@ -76,51 +74,8 @@ struct PropAccessReceiver : Theron::Receiver
* Handle the get and set calls from the user's call-stack
**********************************************************************/
template <typename ActorType>
-static PMCC prop_access_dispatcher(ActorType &actor, const std::string &path, const PMCC &value, const bool set)
+static PMCC prop_access_dispatcher(ActorType &actor, const std::string &key, const PMCC &value, const bool set)
{
- //split the paths into nodes
- std::vector<std::string> nodes;
- boost::split(nodes, path, boost::is_any_of("/"));
-
- //iterate through the path to find the element
- std::string key;
- Element elem = *(actor->block_ptr);
- size_t i = 0;
- BOOST_FOREACH(const std::string &node, nodes)
- {
- i++;
- if (node == "" and i == 1) //find root
- {
- while (elem->_parent) elem = elem->_parent;
- continue;
- }
- if (node == ".") //this dir
- {
- continue;
- }
- if (node == "..") //up a dir
- {
- if (not elem->_parent) throw std::runtime_error(
- "Property tree lookup fail - null parent: " + path
- );
- elem = elem->_parent;
- continue;
- }
- if (i == nodes.size() or elem->block) //leaf
- {
- key = node;
- if (i != nodes.size() or not elem->block) throw std::runtime_error(
- "Property tree lookup fail - beyond leaf: " + path
- );
- continue;
- }
- if (elem->_subelems.count(node) == 0) throw std::runtime_error(
- "Property tree lookup fail - no such path: " + path
- );
- elem = elem->_subelems[node];
- }
-
- //now send a message to the actor to perform the action
PropAccessReceiver receiver;
PropAccessMessage message;
message.set = set;