diff options
author | Josh Blum | 2013-07-06 17:02:24 -0700 |
---|---|---|
committer | Josh Blum | 2013-07-06 17:02:24 -0700 |
commit | c6f6b12bf8429325407ae76f7ead8d3d72232f99 (patch) | |
tree | 6eb92f4630c4e911efa48d239a372b148c5e5e44 /include | |
parent | 9ab885db8eb80c4046af20e1a361b304b5478686 (diff) | |
download | sandhi-c6f6b12bf8429325407ae76f7ead8d3d72232f99.tar.gz sandhi-c6f6b12bf8429325407ae76f7ead8d3d72232f99.tar.bz2 sandhi-c6f6b12bf8429325407ae76f7ead8d3d72232f99.zip |
gras: locate_element since now elements have calls
Diffstat (limited to 'include')
-rw-r--r-- | include/gras/block.i | 5 | ||||
-rw-r--r-- | include/gras/callable.hpp | 8 | ||||
-rw-r--r-- | include/gras/element.hpp | 8 | ||||
-rw-r--r-- | include/gras/element.i | 5 |
4 files changed, 19 insertions, 7 deletions
diff --git a/include/gras/block.i b/include/gras/block.i index 2ba9779..0fed36d 100644 --- a/include/gras/block.i +++ b/include/gras/block.i @@ -19,8 +19,11 @@ %include <gras/block.hpp> //////////////////////////////////////////////////////////////////////// -// Create pythonic gateway to get and set +// Create pythonic methods //////////////////////////////////////////////////////////////////////// +%pythoncode %{ +from PMC import * +%} %extend gras::Block { %insert("python") diff --git a/include/gras/callable.hpp b/include/gras/callable.hpp index ad74dd7..9d24c83 100644 --- a/include/gras/callable.hpp +++ b/include/gras/callable.hpp @@ -31,8 +31,9 @@ namespace gras * - The overloaded () operator sucks with pointers. * - The overloaded () operator has template issues. */ -struct GRAS_API Callable +class GRAS_API Callable { +public: //! Default constructor Callable(void); @@ -42,6 +43,7 @@ struct GRAS_API Callable /******************************************************************* * Register API - don't look here, template magic, not helpful ******************************************************************/ +protected: template <typename ClassType, typename ReturnType> void register_call(const std::string &key, ReturnType(ClassType::*fcn)(void)); @@ -69,6 +71,7 @@ struct GRAS_API Callable /******************************************************************* * Call API - don't look here, template magic, not helpful ******************************************************************/ +public: template <typename ReturnType> ReturnType x(const std::string &key); @@ -96,8 +99,11 @@ struct GRAS_API Callable /******************************************************************* * Private registration hooks ******************************************************************/ +protected: void _register_call(const std::string &, void *); +public: virtual PMCC _handle_call(const std::string &, const PMCC &); +private: boost::shared_ptr<void> _call_registry; }; diff --git a/include/gras/element.hpp b/include/gras/element.hpp index 9b46d76..df47bef 100644 --- a/include/gras/element.hpp +++ b/include/gras/element.hpp @@ -105,7 +105,7 @@ struct GRAS_API Element : Callable, boost::shared_ptr<ElementImpl> void adopt_element(const std::string &name, const Element &child); /*! - * Locate a block in the element tree hierarchy. + * Locate an element 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. @@ -113,10 +113,10 @@ struct GRAS_API Element : Callable, boost::shared_ptr<ElementImpl> * 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 + * \param path a path to an element (leaf) in the tree + * \return a pointer to the element object */ - Block *locate_block(const std::string &path); + Element *locate_element(const std::string &path); }; diff --git a/include/gras/element.i b/include/gras/element.i index 8fbba00..38055a1 100644 --- a/include/gras/element.i +++ b/include/gras/element.i @@ -12,6 +12,8 @@ namespace gras { %ignore Element::set_container; + %ignore Callable::x; + %ignore Callable::register_call; } //////////////////////////////////////////////////////////////////////// @@ -23,9 +25,10 @@ namespace gras // Export swig element comprehension //////////////////////////////////////////////////////////////////////// %include <std_string.i> +%import <PMC/PMC.i> %include <gras/gras.hpp> +%include <gras/callable.hpp> %include <gras/element.hpp> -%import <PMC/PMC.i> //////////////////////////////////////////////////////////////////////// // Operator overloads for Element |