From fb55fd6737902ed6270c2518bdc81a6971f9b3a1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 10 Apr 2013 00:21:31 -0700 Subject: gras: formalize the weak container api w/ docs address issue #69, we now have a set_container call, which is now formally part of the api. Anyone can call set_container for custom container types. GRAS supports shared ptr and pyobject out of the box. --- include/gras/detail/element.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'include/gras/detail') diff --git a/include/gras/detail/element.hpp b/include/gras/detail/element.hpp index f8a8904..8d3e20e 100644 --- a/include/gras/detail/element.hpp +++ b/include/gras/detail/element.hpp @@ -9,9 +9,9 @@ namespace gras { //! Weak element overload for the case of shared_ptr container - struct WeakElementSharedPtr : WeakElement + struct WeakContainerSharedPtr : WeakContainer { - WeakElementSharedPtr(boost::weak_ptr weak_self) + WeakContainerSharedPtr(boost::weak_ptr weak_self) { _weak_self = weak_self; } @@ -25,12 +25,8 @@ namespace gras template inline Element::Element(const boost::shared_ptr &elem) { - //the container is a shared pointer, so save the reference, - //unless the reference was already set to something - if (not elem->weak_self) - { - elem->weak_self.reset(new WeakElementSharedPtr(elem)); - } + //the container is a shared pointer, so save the reference + elem->set_container(new WeakContainerSharedPtr(elem)); //initialize this new Element from the argument passed *this = *elem; -- cgit