diff options
author | Tom Rondeau | 2010-11-04 12:33:20 -0400 |
---|---|---|
committer | Tom Rondeau | 2010-11-04 12:33:20 -0400 |
commit | 309b05cbb38125a910b6199f7adc4ff93bc98064 (patch) | |
tree | a184bb364449e60f72098c127fbcec4c5509a9bb /gnuradio-core | |
parent | 779f498c46175bb12828c9db4643eada3e364b16 (diff) | |
download | gnuradio-309b05cbb38125a910b6199f7adc4ff93bc98064.tar.gz gnuradio-309b05cbb38125a910b6199f7adc4ff93bc98064.tar.bz2 gnuradio-309b05cbb38125a910b6199f7adc4ff93bc98064.zip |
Changing API to match changes to gr_block, including adding "srcid" param to add_item_tag. Added documentation to header file. Changing to deque from list. Still holding the deque locally in block_detail, but will be moved to gr_buffer. Adding tag just builds the tag tuple and appends it; doesn't worry about duplications.
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.cc | 61 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.h | 72 |
2 files changed, 81 insertions, 52 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index d12d808e9..2ab762a30 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2009 Free Software Foundation, Inc. + * Copyright 2004,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -149,59 +149,39 @@ gr_block_detail::nitems_written(unsigned int which_output) void gr_block_detail::add_item_tag(unsigned int which_output, - gr_uint64 offset, + gr_uint64 abs_offset, const pmt::pmt_t &key, - const pmt::pmt_t &value) + const pmt::pmt_t &value, + const pmt::pmt_t &srcid) { if(pmt::pmt_is_symbol(key) == false) { throw pmt::pmt_wrong_type("gr_block_detail::set_item_tag key", key); } else { - bool duplicate = false; - - // Search through list of tags to see if new tag is a duplicate - std::list<pmt::pmt_t>::reverse_iterator itr = d_item_tags.rbegin(); - while(itr != d_item_tags.rend()) { - // find the last item with this key if there is one - if(pmt::pmt_eqv(pmt::pmt_tuple_ref(*itr, 2), key)) { - // check if this value is the same as last; its a duplicate if yes - if(pmt::pmt_eqv(pmt::pmt_tuple_ref(*itr, 3), value)) { - duplicate = true; - } - break; // only looking for the last item of this key - } - itr++; - } - - // It not a duplicate, add new tag to the list - if(!duplicate) { - pmt::pmt_t nitem = pmt::pmt_from_uint64(offset); - pmt::pmt_t stream = pmt::pmt_string_to_symbol("NULL"); - pmt::pmt_t tuple = pmt::pmt_make_tuple(nitem, stream, key, value); - d_item_tags.push_back(tuple); - } - - // need to add prunning routine + pmt::pmt_t nitem = pmt::pmt_from_uint64(abs_offset); + pmt::pmt_t tuple = pmt::pmt_make_tuple(nitem, srcid, key, value); + d_item_tags.push_back(tuple); } } -std::list<pmt::pmt_t> +std::deque<pmt::pmt_t> gr_block_detail::get_tags_in_range(unsigned int which_output, - gr_uint64 start, gr_uint64 end) + gr_uint64 abs_start, + gr_uint64 abs_end) { - std::list<pmt::pmt_t> found_items; - std::list<pmt::pmt_t>::iterator itr = d_item_tags.begin(); + std::deque<pmt::pmt_t> found_items; + std::deque<pmt::pmt_t>::iterator itr = d_item_tags.begin(); gr_uint64 item_time; while(itr != d_item_tags.end()) { 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) { + if(item_time > abs_end) { break; } - if((item_time >= start) && (item_time <= end)) { + if((item_time >= abs_start) && (item_time <= abs_end)) { found_items.push_back(*itr); } @@ -211,13 +191,14 @@ gr_block_detail::get_tags_in_range(unsigned int which_output, return found_items; } -std::list<pmt::pmt_t> +std::deque<pmt::pmt_t> gr_block_detail::get_tags_in_range(unsigned int which_output, - gr_uint64 start, gr_uint64 end, + gr_uint64 abs_start, + gr_uint64 abs_end, const pmt::pmt_t &key) { - std::list<pmt::pmt_t> found_items; - std::list<pmt::pmt_t>::iterator itr = d_item_tags.begin(); + std::deque<pmt::pmt_t> found_items; + std::deque<pmt::pmt_t>::iterator itr = d_item_tags.begin(); gr_uint64 item_time; pmt::pmt_t itemkey; @@ -225,12 +206,12 @@ gr_block_detail::get_tags_in_range(unsigned int which_output, 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) { + if(item_time > abs_end) { break; } itemkey = pmt::pmt_tuple_ref(*itr, 2); - if((item_time >= start) && (item_time <= end) && pmt::pmt_eqv(key, itemkey)) { + if((item_time >= abs_start) && (item_time <= abs_end) && pmt::pmt_eqv(key, itemkey)) { found_items.push_back(*itr); } diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index ee226a349..547d7c22f 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2009 Free Software Foundation, Inc. + * Copyright 2004,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -94,18 +94,66 @@ class gr_block_detail { // Return the number of items written on output stream which_output gr_uint64 nitems_written(unsigned int which_output); - // 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, - 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); + /*! + * \brief Adds a new tag to the deque of tags on a given buffer. + * + * Adds a new tag to deque of tags on a given buffer. This takes the input + * parameters and builds a PMT tuple from it. It then calls + * gr_buffer::add_item_tag(pmt::pmt_t t), which appends the + * tag onto its deque of tags. + * + * \param which_ouput an integer of which output stream to attach the tag + * \param abs_offset a uint64 number of the absolute item number + * assicated with the tag. Can get from nitems_written. + * \param key a PMT symbol holding the key name (i.e., a string) + * \param value any PMT holding any value for the given key + * \param srcid a PMT source ID specifier + */ + void add_item_tag(unsigned int which_output, + gr_uint64 abs_offset, + const pmt::pmt_t &key, + const pmt::pmt_t &value, + const pmt::pmt_t &srcid); + + /*! + * \brief Given a [start,end), returns a deque copy of all tags in the range. + * + * Pass-through function to gr_buffer to get a deque of tags in given range. + * Range of counts is from start to end-1. + * + * Tags are tuples of: + * (item count, source id, key, value) + * + * \param which_input an integer of which input stream to pull from + * \param abs_start a uint64 count of the start of the range of interest + * \param abs_end a uint64 count of the end of the range of interest + */ + std::deque<pmt::pmt_t> get_tags_in_range(unsigned int which_input, + gr_uint64 abs_start, + gr_uint64 abs_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); + /*! + * \brief Given a [start,end), returns a deque copy of all tags in the range + * with a given key. + * + * Calls get_tags_in_range(which_input, abs_start, abs_end) to get a deque of + * tags from the buffers. This function then provides a secondary filter to + * the tags to extract only tags with the given 'key'. Returns a dequeu + * of these tags. + * + * Tags are tuples of: + * (item count, source id, key, value) + * + * \param which_input an integer of which input stream to pull from + * \param abs_start a uint64 count of the start of the range of interest + * \param abs_end a uint64 count of the end of the range of interest + * \param key a PMT symbol key to filter only tags of this key + */ + std::deque<pmt::pmt_t> get_tags_in_range(unsigned int which_input, + gr_uint64 abs_start, + gr_uint64 abs_end, + const pmt::pmt_t &key); gr_tpb_detail d_tpb; // used by thread-per-block scheduler int d_produce_or; @@ -117,7 +165,7 @@ class gr_block_detail { unsigned int d_noutputs; std::vector<gr_buffer_reader_sptr> d_input; std::vector<gr_buffer_sptr> d_output; - std::list<pmt::pmt_t> d_item_tags; + std::deque<pmt::pmt_t> d_item_tags; bool d_done; |