diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gras/detail/element.hpp | 11 | ||||
-rw-r--r-- | include/gras/element.hpp | 20 |
2 files changed, 17 insertions, 14 deletions
diff --git a/include/gras/detail/element.hpp b/include/gras/detail/element.hpp index 35033e1..2b97c8f 100644 --- a/include/gras/detail/element.hpp +++ b/include/gras/detail/element.hpp @@ -11,17 +11,6 @@ namespace gras *this = elem->shared_to_element(); } - //! Convert a shared ptr of a derived class to an Element - inline Element &Element::shared_to_element(void) - { - try - { - this->weak_self = this->shared_from_this(); - } - catch(...){} - return *this; - } - } //namespace gras #endif /*INCLUDED_GRAS_DETAIL_ELEMENT_HPP*/ diff --git a/include/gras/element.hpp b/include/gras/element.hpp index 40a24cf..cfaa5e4 100644 --- a/include/gras/element.hpp +++ b/include/gras/element.hpp @@ -21,6 +21,20 @@ typedef boost::shared_ptr<ElementImpl> ElementBase; struct Block; +/*! + * Weak Element interface class: + * Allows internals to get a reference to the container holding an element. + * This container could be a shared_ptr or perhaps a Python object. + */ +struct WeakElement +{ + //! Lock creates a shared pointer holding a container reference + virtual boost::shared_ptr<void> lock(void) = 0; +}; + +/*! + * Element is a base class for all topological elements. + */ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element> { //! Create an empty element @@ -87,13 +101,13 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element> * Good for that factory function/shared ptr paradigm. */ template <typename T> - inline Element(const boost::shared_ptr<T> &elem); + Element(const boost::shared_ptr<T> &elem); //! Convert a shared ptr of a derived class to an Element - inline Element &shared_to_element(void); + Element &shared_to_element(void); //! for internal use only - boost::weak_ptr<Element> weak_self; + boost::shared_ptr<WeakElement> weak_self; }; |