GNU Radio Manual and C++ API Reference  3.9.0.0
The Free & Open Software Radio Ecosystem
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  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_GR_RUNTIME_TAG_CHECKER_H
12 #define INCLUDED_GR_RUNTIME_TAG_CHECKER_H
13 
14 #include <gnuradio/tags.h>
15 #include <vector>
16 
17 namespace gr {
18 
20 {
21 private:
22  std::vector<tag_t> d_tags;
23  tag_t d_next_tag;
24  bool d_has_next_tag;
25  unsigned int d_next_tag_index;
26 
27 public:
28  tag_checker(std::vector<tag_t>& tags) : d_has_next_tag(false), d_next_tag_index(0)
29  {
30  d_tags = tags;
31  std::sort(d_tags.begin(), d_tags.end(), &gr::tag_t::offset_compare);
32  if (!d_tags.empty()) {
33  d_has_next_tag = true;
34  d_next_tag = tags[0];
35  }
36  };
37 
39 
40  void get_tags(std::vector<tag_t>& tag_list, unsigned int offset)
41  {
42  while (d_has_next_tag && (offset >= d_next_tag.offset)) {
43  if (offset == d_next_tag.offset) {
44  tag_list.push_back(d_next_tag);
45  }
46  d_next_tag_index += 1;
47  if (d_next_tag_index >= d_tags.size()) {
48  d_has_next_tag = false;
49  } else {
50  d_next_tag = d_tags[d_next_tag_index];
51  }
52  }
53  };
54 };
55 } // namespace gr
56 
57 #endif /* INCLUDED_GR_RUNTIME_TAG_CHECKER_H */
Definition: tag_checker.h:20
tag_checker(std::vector< tag_t > &tags)
Definition: tag_checker.h:28
void get_tags(std::vector< tag_t > &tag_list, unsigned int offset)
Definition: tag_checker.h:40
~tag_checker()
Definition: tag_checker.h:38
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29
Definition: tags.h:19
static bool offset_compare(const tag_t &x, const tag_t &y)
Definition: tags.h:40
uint64_t offset
the item tag occurred at (as a uint64_t)
Definition: tags.h:21