summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/runtime/gr_block.h
diff options
context:
space:
mode:
authorJosh Blum2013-03-17 23:12:31 -0700
committerJosh Blum2013-03-17 23:12:31 -0700
commitbfefd11011987fe9755dd72d86ad4f052b3d263e (patch)
tree73b3960d46caed9996dfeff4856c3bcc546c9006 /gnuradio-core/src/lib/runtime/gr_block.h
parentcb5ff01c491d4558a096fc1649b85283c36ccf91 (diff)
parent3693ee3259fa8bf2d9ad393842a80cd1fc330863 (diff)
downloadgnuradio-bfefd11011987fe9755dd72d86ad4f052b3d263e.tar.gz
gnuradio-bfefd11011987fe9755dd72d86ad4f052b3d263e.tar.bz2
gnuradio-bfefd11011987fe9755dd72d86ad4f052b3d263e.zip
Merge branch 'maint' of https://github.com/guruofquality/gnuradio into v3.6.4git_gras_support
Conflicts: gnuradio-core/src/lib/runtime/gr_block.cc gnuradio-core/src/lib/runtime/gr_block.h gnuradio-core/src/lib/runtime/gr_types.h
Diffstat (limited to 'gnuradio-core/src/lib/runtime/gr_block.h')
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h
index 6c6480eb4..9c8485663 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_block.h
@@ -27,10 +27,6 @@
#include <map>
#include <boost/foreach.hpp>
-typedef std::vector<int> gr_vector_int;
-typedef std::vector<void *> gr_vector_void_star;
-typedef std::vector<const void *> gr_vector_const_void_star;
-
namespace gnuradio
{
//! dummy entry, just here for legacy purposes
@@ -227,6 +223,10 @@ struct GR_CORE_API gr_block : gras::Block
msg_queue_map_t msg_queue;
pmt::pmt_t message_subscribers;
+ typedef boost::function<void(pmt::pmt_t)> msg_handler_t;
+ typedef std::map<pmt::pmt_t , msg_handler_t, pmt::pmt_comperator> d_msg_handlers_t;
+ d_msg_handlers_t d_msg_handlers;
+
template <typename T> void set_msg_handler(pmt::pmt_t which_port, T msg_handler){}
void message_port_register_in(pmt::pmt_t /*port_id*/){}
@@ -297,6 +297,27 @@ struct GR_CORE_API gr_block : gras::Block
return false;
}
+ /*!
+ * \brief Tests if there is a handler attached to port \p which_port
+ */
+ bool has_msg_handler(pmt::pmt_t which_port) {
+ return (d_msg_handlers.find(which_port) != d_msg_handlers.end());
+ }
+
+ /*
+ * This function is called by the runtime system to dispatch messages.
+ *
+ * The thread-safety guarantees mentioned in set_msg_handler are implemented
+ * by the callers of this method.
+ */
+ virtual void dispatch_msg(pmt::pmt_t which_port, pmt::pmt_t msg)
+ {
+ // AA Update this
+ if(has_msg_handler(which_port)) { // Is there a handler?
+ d_msg_handlers[which_port](msg); // Yes, invoke it.
+ }
+ }
+
///////////////// private vars //////////////////////
gr_vector_int _work_ninput_items;