summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CMakeLists.txt1
-rw-r--r--lib/element.cpp5
-rw-r--r--lib/element_impl.hpp1
-rw-r--r--lib/hier_block.cpp5
-rw-r--r--lib/weak_container.cpp15
5 files changed, 25 insertions, 2 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index ff36a5a..5d059e7 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -58,6 +58,7 @@ list(APPEND GRAS_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/top_block_query.cpp
${CMAKE_CURRENT_SOURCE_DIR}/register_messages.cpp
${CMAKE_CURRENT_SOURCE_DIR}/theron_allocator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/weak_container.cpp
)
########################################################################
diff --git a/lib/element.cpp b/lib/element.cpp
index 989c184..dfc3f57 100644
--- a/lib/element.cpp
+++ b/lib/element.cpp
@@ -48,6 +48,11 @@ ElementImpl::~ElementImpl(void)
if (this->block) this->block_cleanup();
}
+void Element::set_container(WeakContainer *container)
+{
+ (*this)->weak_self.reset(container);
+}
+
bool Element::equals(const Element &rhs)
{
return this->get() == rhs.get();
diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp
index 869006e..3148d93 100644
--- a/lib/element_impl.hpp
+++ b/lib/element_impl.hpp
@@ -29,6 +29,7 @@ struct ElementImpl
std::string name;
long unique_id;
std::string id;
+ boost::shared_ptr<WeakContainer> weak_self;
//top block stuff
SharedThreadGroup thread_group;
diff --git a/lib/hier_block.cpp b/lib/hier_block.cpp
index d8756a4..758af0c 100644
--- a/lib/hier_block.cpp
+++ b/lib/hier_block.cpp
@@ -40,9 +40,10 @@ void HierBlock::disconnect(const Element &elem)
static Apology::Wax get_ref(const Element &elem)
{
- if (elem.weak_self)
+ boost::shared_ptr<WeakContainer> weak_self = elem->weak_self;
+ if (weak_self)
{
- boost::shared_ptr<const void> shared_self = elem.weak_self->lock();
+ boost::shared_ptr<const void> shared_self = weak_self->lock();
if (shared_self) return shared_self;
}
return elem;
diff --git a/lib/weak_container.cpp b/lib/weak_container.cpp
new file mode 100644
index 0000000..192a2fd
--- /dev/null
+++ b/lib/weak_container.cpp
@@ -0,0 +1,15 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#include <gras/weak_container.hpp>
+
+using namespace gras;
+
+WeakContainer::WeakContainer(void)
+{
+ //NOP
+}
+
+WeakContainer::~WeakContainer(void)
+{
+ //NOP
+}