From 9ea77e78ade12ed5402ed9f3df1f10d9d4d27559 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 22 Mar 2013 01:54:16 -0700 Subject: gras: we now have the element tree interface --- include/gras/element.hpp | 31 +++++++++++++++++++++++++++++++ include/gras/hier_block.hpp | 9 --------- 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'include') 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 ElementBase; +struct Block; + struct GRAS_API Element : ElementBase, boost::enable_shared_from_this { @@ -41,6 +43,35 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this //! get a canonical name for 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 -- cgit