diff options
Diffstat (limited to 'lib/element.cpp')
-rw-r--r-- | lib/element.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/element.cpp b/lib/element.cpp index 6736011..340bd85 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -31,6 +31,33 @@ Element::~Element(void) //NOP } +//! Weak element overload for the case of shared_ptr container +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; +}; + +Element &Element::shared_to_element(void) +{ + try + { + if (not this->weak_self) + { + this->weak_self.reset(new WeakElementSharedPtr(this->shared_from_this())); + } + } + catch(...){} + return *this; +} + ElementImpl::~ElementImpl(void) { if (this->executor) this->top_block_cleanup(); |