From d07a944f0c327b255285a8fef4604b65fa8fd7c8 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 26 Oct 2010 21:01:22 -0400 Subject: First stab at adding get functions for item tags in a given range. --- gnuradio-core/src/lib/runtime/gr_block.cc | 17 ++++++++++- gnuradio-core/src/lib/runtime/gr_block.h | 9 +++++- gnuradio-core/src/lib/runtime/gr_block_detail.cc | 38 +++++++++++++++++++++++- gnuradio-core/src/lib/runtime/gr_block_detail.h | 9 +++++- 4 files changed, 69 insertions(+), 4 deletions(-) (limited to 'gnuradio-core') diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index ed848e3ed..a2b495867 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -129,12 +129,27 @@ gr_block::n_items_written(unsigned int which_output) { void gr_block::add_item_tag(unsigned int which_output, - uint64_t offset, + gr_uint64 offset, const pmt::pmt_t &key, const pmt::pmt_t &value) { d_detail->add_item_tag(which_output, offset, key, value); } +std::list +gr_block::get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end) +{ + return d_detail->get_tags_in_range(which_output, start, end); +} + +std::list +gr_block::get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end, + const pmt::pmt_t &key) +{ + return d_detail->get_tags_in_range(which_output, start, end, key); +} + std::ostream& operator << (std::ostream& os, const gr_block *m) { diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index c4d639314..888ca811a 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -24,6 +24,7 @@ #define INCLUDED_GR_BLOCK_H #include +#include /*! * \brief The abstract base class for all 'terminal' processing blocks. @@ -205,9 +206,15 @@ class gr_block : public gr_basic_block { gr_uint64 n_items_written(unsigned int which_output); void add_item_tag(unsigned int which_output, - uint64_t offset, + gr_uint64 offset, const pmt::pmt_t &key, const pmt::pmt_t &value); + std::list get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end); + + std::list get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end, + const pmt::pmt_t &key); // ---------------------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index 656cdb13a..dbe49f37c 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -141,7 +141,7 @@ gr_block_detail::_post(pmt::pmt_t msg) void gr_block_detail::add_item_tag(unsigned int which_output, - uint64_t offset, + gr_uint64 offset, const pmt::pmt_t &key, const pmt::pmt_t &value) { if(pmt::pmt_is_symbol(key) == false) { @@ -156,3 +156,39 @@ gr_block_detail::add_item_tag(unsigned int which_output, // need to add prunning routing } } + +std::list +gr_block_detail::get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end) +{ + std::list found_items; + std::list::iterator itr = d_item_tags.begin(); + + gr_uint64 item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); + while(itr != d_item_tags.end()) { + if((item_time < start) && (item_time < end)) { + found_items.push_back(*itr); + } + + itr++; + item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); + + // items are pushed onto list in sequential order; stop if we're past end + if(item_time > end) { + break; + } + } + + return found_items; +} + +std::list +gr_block_detail::get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end, + const pmt::pmt_t &key) +{ + std::list found_items; + std::list::iterator itr = d_item_tags.begin(); + + return found_items; +} diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index 6a8d94c72..cb590cec9 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -105,9 +105,16 @@ class gr_block_detail { // Add an item tag tuple to list of tags // -> is this just based on output stream? how to handle this... void add_item_tag(unsigned int which_output, - uint64_t offset, + gr_uint64 offset, const pmt::pmt_t &key, const pmt::pmt_t &value); + std::list get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end); + + std::list get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end, + const pmt::pmt_t &key); + gr_tpb_detail d_tpb; // used by thread-per-block scheduler int d_produce_or; -- cgit