diff options
author | Josh Blum | 2013-04-10 00:21:31 -0700 |
---|---|---|
committer | Josh Blum | 2013-04-10 00:21:31 -0700 |
commit | fb55fd6737902ed6270c2518bdc81a6971f9b3a1 (patch) | |
tree | c31dcb488f97f4c016ad326c726d5f42bcb6bca0 /include/gras/detail/element.hpp | |
parent | ca4819c56e7f085c1358cd75a9f4635ce3ae2f1f (diff) | |
download | sandhi-fb55fd6737902ed6270c2518bdc81a6971f9b3a1.tar.gz sandhi-fb55fd6737902ed6270c2518bdc81a6971f9b3a1.tar.bz2 sandhi-fb55fd6737902ed6270c2518bdc81a6971f9b3a1.zip |
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.
Diffstat (limited to 'include/gras/detail/element.hpp')
-rw-r--r-- | include/gras/detail/element.hpp | 12 |
1 files changed, 4 insertions, 8 deletions
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<const void> weak_self) + WeakContainerSharedPtr(boost::weak_ptr<const void> weak_self) { _weak_self = weak_self; } @@ -25,12 +25,8 @@ namespace gras template <typename T> inline Element::Element(const boost::shared_ptr<T> &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; |