diff options
author | Josh Blum | 2012-09-03 05:44:53 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-03 05:44:53 -0700 |
commit | d3c303b2f78e3657dc89e23478316502cedc6e7b (patch) | |
tree | 08d1e2f9262a59349f5042cbe5c3eab2638cfa6d /include/gnuradio/element.hpp | |
parent | b9d92f31d7eee9bf1707fa622b6bea531e41c693 (diff) | |
download | sandhi-d3c303b2f78e3657dc89e23478316502cedc6e7b.tar.gz sandhi-d3c303b2f78e3657dc89e23478316502cedc6e7b.tar.bz2 sandhi-d3c303b2f78e3657dc89e23478316502cedc6e7b.zip |
created shared_to_element and use shared_from_this
Allows element to be used in a derived class w/
or without a shared pointer. Python/C++
Diffstat (limited to 'include/gnuradio/element.hpp')
-rw-r--r-- | include/gnuradio/element.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/gnuradio/element.hpp b/include/gnuradio/element.hpp index 51c79b8..4cad346 100644 --- a/include/gnuradio/element.hpp +++ b/include/gnuradio/element.hpp @@ -21,6 +21,7 @@ #include <gnuradio/io_signature.hpp> #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> //this is part of core for now, treat it as such #include <gr_core_api.h> @@ -31,7 +32,7 @@ namespace gnuradio struct ElementImpl; -struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl> +struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl>, boost::enable_shared_from_this<Element> { //! Create an empty element @@ -47,12 +48,11 @@ struct GR_RUNTIME_API Element : boost::shared_ptr<ElementImpl> template <typename T> Element(const boost::shared_ptr<T> &elem) { - *this = *elem; - weak_self = elem; + *this = elem->shared_to_element(); } - //! Get the derived class as an element - const Element &get_base(void) const; + //! Convert a shared ptr of a derived class to an Element + Element &shared_to_element(void); //! for internal use only boost::weak_ptr<Element> weak_self; |