summaryrefslogtreecommitdiff
path: root/include/gras/detail/element.hpp
diff options
context:
space:
mode:
authorJosh Blum2013-04-03 23:09:49 -0700
committerJosh Blum2013-04-03 23:09:49 -0700
commit0651aff49ae7e066bc301faeecfbd519c4743849 (patch)
tree540884afb2ce0186ce951258359c8effb6ed9aa6 /include/gras/detail/element.hpp
parent3e0943d0e61b11cdd6b0b2dd7d0815a64e63725d (diff)
downloadsandhi-0651aff49ae7e066bc301faeecfbd519c4743849.tar.gz
sandhi-0651aff49ae7e066bc301faeecfbd519c4743849.tar.bz2
sandhi-0651aff49ae7e066bc301faeecfbd519c4743849.zip
gras: figured out how to do the python reference
Diffstat (limited to 'include/gras/detail/element.hpp')
-rw-r--r--include/gras/detail/element.hpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/gras/detail/element.hpp b/include/gras/detail/element.hpp
index 35033e1..22a63a0 100644
--- a/include/gras/detail/element.hpp
+++ b/include/gras/detail/element.hpp
@@ -5,6 +5,19 @@
namespace gras
{
+ struct WeakElementSharedPtr : WeakElement
+ {
+ WeakElementSharedPtr(boost::weak_ptr<Element> weak_self)
+ {
+ _weak_self = weak_self;
+ }
+ boost::shared_ptr<void> lock(void)
+ {
+ return _weak_self.lock();
+ }
+ boost::weak_ptr<Element> _weak_self;
+ };
+
template <typename T>
inline Element::Element(const boost::shared_ptr<T> &elem)
{
@@ -16,7 +29,8 @@ namespace gras
{
try
{
- this->weak_self = this->shared_from_this();
+ if (not this->weak_self)
+ this->weak_self.reset(new WeakElementSharedPtr(this->shared_from_this()));
}
catch(...){}
return *this;