diff options
author | Tom Rondeau <trondeau@vt.edu> | 2010-11-04 18:16:26 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2010-11-04 18:16:26 -0400 |
commit | 70ca24e7cc6ba744589e3d5fb8077f706e813d28 (patch) | |
tree | 6ac84764d2d20483546c392fc92ebd6ba560723a /gnuradio-core/src/lib/runtime/gr_buffer.cc | |
parent | ef9ff4ce4ab97a557f08fa5dad091b0cf63d313f (diff) |
Moving add_item_tag into gr_buffer and get_tags_in_range to gr_buffer_reader. gr_block_detail takes care of the high-level adding and retrieving tags via the buffers/readers; also takes care of filtering tags by key.
Tags are now added to the gr_buffers on 'which_output' while they are retrieved from the gr_buffer_reader based on 'which_input."
Diffstat (limited to 'gnuradio-core/src/lib/runtime/gr_buffer.cc')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_buffer.cc | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index 89db99b698..da7866f489 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.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 * @@ -216,6 +216,12 @@ gr_buffer::drop_reader (gr_buffer_reader *reader) d_readers.erase (result); } +void +gr_buffer::add_item_tag(const pmt::pmt_t &tag) +{ + d_item_tags.push_back(tag); +} + long gr_buffer_ncurrently_allocated () { @@ -257,6 +263,33 @@ gr_buffer_reader::update_read_pointer (int nitems) d_abs_read_offset += nitems; } +std::deque<pmt::pmt_t> +gr_buffer_reader::get_tags_in_range(unsigned int which_output, + gr_uint64 abs_start, + gr_uint64 abs_end) +{ + 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 > abs_end) { + break; + } + + if((item_time >= abs_start) && (item_time <= abs_end)) { + found_items.push_back(*itr); + } + + itr++; + } + + return found_items; +} + long gr_buffer_reader_ncurrently_allocated () { |