diff options
author | Josh Blum | 2013-03-22 01:54:16 -0700 |
---|---|---|
committer | Josh Blum | 2013-03-22 01:54:16 -0700 |
commit | 9ea77e78ade12ed5402ed9f3df1f10d9d4d27559 (patch) | |
tree | 7355daec02ae124dfd89b821bd21723239f0f03a /include/gras | |
parent | a54708334425472d277e77c394688bab4cac607a (diff) | |
download | sandhi-9ea77e78ade12ed5402ed9f3df1f10d9d4d27559.tar.gz sandhi-9ea77e78ade12ed5402ed9f3df1f10d9d4d27559.tar.bz2 sandhi-9ea77e78ade12ed5402ed9f3df1f10d9d4d27559.zip |
gras: we now have the element tree interface
Diffstat (limited to 'include/gras')
-rw-r--r-- | include/gras/element.hpp | 31 | ||||
-rw-r--r-- | include/gras/hier_block.hpp | 9 |
2 files changed, 31 insertions, 9 deletions
diff --git a/include/gras/element.hpp b/include/gras/element.hpp index 3211ac3..13ebb7c 100644 --- a/include/gras/element.hpp +++ b/include/gras/element.hpp @@ -19,6 +19,8 @@ struct ElementImpl; typedef boost::shared_ptr<ElementImpl> ElementBase; +struct Block; + struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element> { @@ -42,6 +44,35 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element> std::string to_string(void) const; /******************************************************************* + * element tree interface + ******************************************************************/ + + /*! + * Adopt an element as a child under the given name. + * + * This API allows the user to structure a hierarchy of elements. + * This element will become the parent of the child element. + * + * \param name the name of the child node + * \param child an element to be adopted + */ + void adopt_element(const std::string &name, const Element &child); + + /*! + * Lookup a block in the element tree hierarchy. + * + * Paths are unix style, absolte and relatives paths are possible. + * This call throws an invalid argument when bad paths are given. + * + * Example path: /my_hier_block/my_block0 + * Example path: ../my_block1 + * + * \param path a path to a block (leaf) in the tree + * \return a pointer to the block + */ + Block *lookup_block(const std::string &path); + + /******************************************************************* * Compatibility for dealing with shared ptrs of Elements ******************************************************************/ /*! diff --git a/include/gras/hier_block.hpp b/include/gras/hier_block.hpp index 25c1424..398024e 100644 --- a/include/gras/hier_block.hpp +++ b/include/gras/hier_block.hpp @@ -44,15 +44,6 @@ struct GRAS_API HierBlock : Element */ virtual void commit(void); - /******************************************************************* - * property tree interface - ******************************************************************/ - - /*! - * Register a subelement's properties into this element. - */ - void register_subelement(const std::string &node, const Element &subelem); - }; } //namespace gras |