diff options
author | Tom Rondeau | 2010-10-26 21:01:22 -0400 |
---|---|---|
committer | Tom Rondeau | 2010-10-26 21:01:22 -0400 |
commit | d07a944f0c327b255285a8fef4604b65fa8fd7c8 (patch) | |
tree | 14b7946ef3e528e1f322f4b6851e1920e2c34b5b /gnuradio-core | |
parent | b22efee47c7d891a8c10b1493f20976534fdb751 (diff) | |
download | gnuradio-d07a944f0c327b255285a8fef4604b65fa8fd7c8.tar.gz gnuradio-d07a944f0c327b255285a8fef4604b65fa8fd7c8.tar.bz2 gnuradio-d07a944f0c327b255285a8fef4604b65fa8fd7c8.zip |
First stab at adding get functions for item tags in a given range.
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.cc | 17 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.h | 9 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.cc | 38 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.h | 9 |
4 files changed, 69 insertions, 4 deletions
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<pmt::pmt_t> +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<pmt::pmt_t> +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 <gr_basic_block.h> +#include <list> /*! * \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<pmt::pmt_t> get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end); + + std::list<pmt::pmt_t> 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<pmt::pmt_t> +gr_block_detail::get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end) +{ + std::list<pmt::pmt_t> found_items; + std::list<pmt::pmt_t>::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<pmt::pmt_t> +gr_block_detail::get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end, + const pmt::pmt_t &key) +{ + std::list<pmt::pmt_t> found_items; + std::list<pmt::pmt_t>::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<pmt::pmt_t> get_tags_in_range(unsigned int which_output, + gr_uint64 start, gr_uint64 end); + + std::list<pmt::pmt_t> 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; |