diff options
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/basic_block.h')
-rw-r--r-- | gnuradio-runtime/include/gnuradio/basic_block.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gnuradio-runtime/include/gnuradio/basic_block.h b/gnuradio-runtime/include/gnuradio/basic_block.h index 7a265cd05e..3816e8ab98 100644 --- a/gnuradio-runtime/include/gnuradio/basic_block.h +++ b/gnuradio-runtime/include/gnuradio/basic_block.h @@ -127,6 +127,18 @@ protected: // Message passing interface pmt::pmt_t d_message_subscribers; + /*! + * \brief This is meant to be called by derived classes (e.g. block) to get + * a shared pointer internally. This is needed because + * std::enable_shared_from_this doesn't seem to work with derived classes + * in an inheritance hierarchy. + */ + template <typename Derived> + std::shared_ptr<Derived> shared_from_base() + { + return std::static_pointer_cast<Derived>(shared_from_this()); + } + public: pmt::pmt_t message_subscribers(pmt::pmt_t port); ~basic_block() override; |