diff options
author | Tom Rondeau | 2010-11-07 18:39:15 -0500 |
---|---|---|
committer | Tom Rondeau | 2010-11-07 18:39:15 -0500 |
commit | 23285af07c88890daea3c9da011f983ae0e0da2d (patch) | |
tree | 4da021c873caae38e3d05c65b82f6acaedb33648 | |
parent | 3bf4a8423acded7743470adffcd9dcc57b049560 (diff) | |
download | gnuradio-23285af07c88890daea3c9da011f983ae0e0da2d.tar.gz gnuradio-23285af07c88890daea3c9da011f983ae0e0da2d.tar.bz2 gnuradio-23285af07c88890daea3c9da011f983ae0e0da2d.zip |
Moving tag handling setup back into gr_block so it can be set in the constructor of a derived block.
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.cc | 15 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.h | 15 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.cc | 19 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.h | 11 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_executor.cc | 20 |
5 files changed, 38 insertions, 42 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 1fb4633e5..94cf23103 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -36,7 +36,8 @@ gr_block::gr_block (const std::string &name, d_output_multiple (1), d_relative_rate (1.0), d_history(1), - d_fixed_rate(false) + d_fixed_rate(false), + d_tag_handling_method(TAGS_ALL_TO_ALL) { } @@ -166,16 +167,22 @@ gr_block::get_tags_in_range(unsigned int which_output, return d_detail->get_tags_in_range(which_output, start, end, key); } -int +int gr_block::tag_handling_method() { - return d_detail->tag_handling_method(); + return d_tag_handling_method; } void gr_block::set_tag_handling_method(int m) { - set_tag_handling_method(m); + /* + if((m == TAGS_ONE_TO_ONE) && (ninputs() != noutputs())) { + throw std::invalid_argument ("gr_block::set_handling method to ONE-TO-ONE requires ninputs == noutputs"); + } + */ + + d_tag_handling_method = m; } std::ostream& diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 4b246884e..e278e8e9c 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -25,6 +25,12 @@ #include <gr_basic_block.h> +enum { + TAGS_NONE = 0, + TAGS_ALL_TO_ALL = 1, + TAGS_ONE_TO_ONE = 2 +}; + /*! * \brief The abstract base class for all 'terminal' processing blocks. * \ingroup base_blk @@ -208,7 +214,14 @@ class gr_block : public gr_basic_block { */ uint64_t nitems_written(unsigned int which_output); + /*! + * \brief Asks for the method used by the scheduler to moved tags downstream. + */ int tag_handling_method(); + + /*! + * \brief Used by the scheduler to determine how tags are moved downstream. + */ void set_tag_handling_method(int m); // ---------------------------------------------------------------------------- @@ -220,6 +233,7 @@ class gr_block : public gr_basic_block { gr_block_detail_sptr d_detail; // implementation details unsigned d_history; bool d_fixed_rate; + int d_tag_handling_method; protected: @@ -285,7 +299,6 @@ class gr_block : public gr_basic_block { uint64_t abs_end, const pmt::pmt_t &key); - // These are really only for internal use, but leaving them public avoids // having to work up an ever-varying list of friends diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index b7dc52a60..1888b8839 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -41,8 +41,7 @@ gr_block_detail::gr_block_detail (unsigned int ninputs, unsigned int noutputs) : d_produce_or(0), d_ninputs (ninputs), d_noutputs (noutputs), d_input (ninputs), d_output (noutputs), - d_done (false), - d_tag_handling_method(gr_block_detail::TAGS_ALL_TO_ALL) + d_done (false) { s_ncurrently_allocated++; } @@ -202,19 +201,3 @@ gr_block_detail::get_tags_in_range(unsigned int which_input, return found_items_by_key; } - -int -gr_block_detail::tag_handling_method() -{ - return d_tag_handling_method; -} - -void -gr_block_detail::set_tag_handling_method(int m) -{ - if((m == TAGS_ONE_TO_ONE) && (ninputs() != noutputs())) { - throw std::invalid_argument ("gr_block_detail::set_handling method to ONE-TO-ONE requires ninputs == noutputs"); - } - - d_tag_handling_method = m; -} diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index 711f59cf0..929e36fc8 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -37,13 +37,6 @@ */ class gr_block_detail { public: - - enum { - TAGS_NONE = 0, - TAGS_ALL_TO_ALL = 1, - TAGS_ONE_TO_ONE = 2 - }; - ~gr_block_detail (); int ninputs () const { return d_ninputs; } @@ -160,9 +153,6 @@ class gr_block_detail { uint64_t abs_end, const pmt::pmt_t &key); - int tag_handling_method(); - void set_tag_handling_method(int m); - gr_tpb_detail d_tpb; // used by thread-per-block scheduler int d_produce_or; @@ -174,7 +164,6 @@ class gr_block_detail { std::vector<gr_buffer_reader_sptr> d_input; std::vector<gr_buffer_sptr> d_output; bool d_done; - int d_tag_handling_method; gr_block_detail (unsigned int ninputs, unsigned int noutputs); diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index f201c3937..3fc536845 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -313,10 +313,10 @@ gr_block_executor::run_one_iteration() // Move tags downstream // if a sink, we don't need to move downstream; // and do not bother if block uses TAGS_NONE attribute - if(!d->sink_p() && (d->tag_handling_method() != gr_block_detail::TAGS_NONE)) { + if(!d->sink_p() && (m->tag_handling_method() != TAGS_NONE)) { // every tag on every input propogates to everyone downstream - if(d->tag_handling_method() == gr_block_detail::TAGS_ALL_TO_ALL) { + if(m->tag_handling_method() == TAGS_ALL_TO_ALL) { for(int i = 0; i < d->ninputs(); i++) { std::vector<pmt::pmt_t> tuple = d->get_tags_in_range(i, start_count[i], end_count[i]); std::vector<pmt::pmt_t>::iterator t; @@ -330,14 +330,18 @@ gr_block_executor::run_one_iteration() // tags from input i only go to output i // this requires d->ninputs() == d->noutputs; this is checked when this // type of tag-handling system is selected in gr_block_detail - else if(d->tag_handling_method() == gr_block_detail::TAGS_ONE_TO_ONE) { - for(int i = 0; i < d->ninputs(); i++) { - std::vector<pmt::pmt_t> tuple = d->get_tags_in_range(i, start_count[i], end_count[i]); - std::vector<pmt::pmt_t>::iterator t; - for(t = tuple.begin(); t != tuple.end(); t++ ) { - d->output(i)->add_item_tag(*t); + else if(m->tag_handling_method() == TAGS_ONE_TO_ONE) { + if(d->ninputs() != d->noutputs()) { + for(int i = 0; i < d->ninputs(); i++) { + std::vector<pmt::pmt_t> tuple = d->get_tags_in_range(i, start_count[i], end_count[i]); + std::vector<pmt::pmt_t>::iterator t; + for(t = tuple.begin(); t != tuple.end(); t++ ) { + d->output(i)->add_item_tag(*t); + } } } + else + throw std::invalid_argument ("handling method 'ONE-TO-ONE' requires ninputs == noutputs"); } // else ; do nothing |