GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
tag_checker.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifndef INCLUDED_GR_RUNTIME_TAG_CHECKER_H
24#define INCLUDED_GR_RUNTIME_TAG_CHECKER_H
25
26#include <gnuradio/tags.h>
27#include <vector>
28
29namespace gr {
30
32{
33private:
34 std::vector<tag_t> d_tags;
35 tag_t d_next_tag;
36 bool d_has_next_tag;
37 unsigned int d_next_tag_index;
38
39public:
40 tag_checker(std::vector<tag_t>& tags) : d_has_next_tag(false), d_next_tag_index(0)
41 {
42 d_tags = tags;
43 std::sort(d_tags.begin(), d_tags.end(), &gr::tag_t::offset_compare);
44 if (!d_tags.empty()) {
45 d_has_next_tag = true;
46 d_next_tag = tags[0];
47 }
48 };
49
51
52 void get_tags(std::vector<tag_t>& tag_list, unsigned int offset)
53 {
54 while (d_has_next_tag && (offset >= d_next_tag.offset)) {
55 if (offset == d_next_tag.offset) {
56 tag_list.push_back(d_next_tag);
57 }
58 d_next_tag_index += 1;
59 if (d_next_tag_index >= d_tags.size()) {
60 d_has_next_tag = false;
61 } else {
62 d_next_tag = d_tags[d_next_tag_index];
63 }
64 }
65 };
66};
67} // namespace gr
68
69#endif /* INCLUDED_GR_RUNTIME_TAG_CHECKER_H */
Definition tag_checker.h:32
tag_checker(std::vector< tag_t > &tags)
Definition tag_checker.h:40
void get_tags(std::vector< tag_t > &tag_list, unsigned int offset)
Definition tag_checker.h:52
~tag_checker()
Definition tag_checker.h:50
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46
Definition tags.h:31
static bool offset_compare(const tag_t &x, const tag_t &y)
Definition tags.h:52
uint64_t offset
the item tag occurred at (as a uint64_t)
Definition tags.h:33