diff options
author | Josh Blum | 2012-08-25 18:18:57 -0700 |
---|---|---|
committer | Josh Blum | 2012-08-26 16:03:52 -0700 |
commit | a18022dc2cb84f4164ec812178517c6549c087ed (patch) | |
tree | 898d722467e61ed1de6c7bf4b3c8f8765e1ebff9 /lib/block_handlers.cpp | |
parent | cba829a42111bf1d8a4393b6e0048897064f415a (diff) | |
download | sandhi-a18022dc2cb84f4164ec812178517c6549c087ed.tar.gz sandhi-a18022dc2cb84f4164ec812178517c6549c087ed.tar.bz2 sandhi-a18022dc2cb84f4164ec812178517c6549c087ed.zip |
work on tag prop policy impl
Diffstat (limited to 'lib/block_handlers.cpp')
-rw-r--r-- | lib/block_handlers.cpp | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp index 6db9c92..262abea 100644 --- a/lib/block_handlers.cpp +++ b/lib/block_handlers.cpp @@ -15,6 +15,7 @@ // along with io_sig program. If not, see <http://www.gnu.org/licenses/>. #include "element_impl.hpp" +#include <boost/foreach.hpp> #include <algorithm> using namespace gnuradio; @@ -95,17 +96,56 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface) std::sort(tags_i.begin(), tags_i.end(), Tag::offset_compare); } - //trim the input tags that are past the consumption zone for (size_t i = 0; i < num_inputs; i++) { std::vector<Tag> &tags_i = this->input_tags[i]; const size_t items_consumed_i = this->items_consumed[i]; - size_t j = 0; - while (j < tags_i.size() and tags_i[j].offset < items_consumed_i) + size_t last = 0; + while (last < tags_i.size() and tags_i[last].offset < items_consumed_i) + { + last++; + } + + //follow the tag propagation policy before erasure + switch (this->tag_prop_policy) + { + case Block::TPP_DONT: break; //well that was ez + case Block::TPP_ALL_TO_ALL: + for (size_t out_i = 0; out_i < num_outputs; out_i++) + { + for (size_t tag_i = 0; tag_i < last; tag_i++) + { + Tag t = tags_i[tag_i]; + t.offset *= this->relative_rate; + task_iface.post_downstream(out_i, t); + } + } + break; + case Block::TPP_ONE_TO_ONE: + if (i < num_outputs) + { + for (size_t tag_i = 0; tag_i < last; tag_i++) + { + Tag t = tags_i[tag_i]; + t.offset *= this->relative_rate; + task_iface.post_downstream(i, t); + } + } + break; + }; + + //now its safe to perform the erasure + if (last != 0) tags_i.erase(tags_i.begin(), tags_i.begin()+last); + } + + //now commit all tags in the output queue to the downstream msg handler + for (size_t i = 0; i < num_outputs; i++) + { + BOOST_FOREACH(const Tag &t, this->output_tags[i]) { - j++; + task_iface.post_downstream(i, t); } - if (j != 0) tags_i.erase(tags_i.begin(), tags_i.begin()+j); + this->output_tags[i].clear(); } } |