GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 <vector>
27 #include <gnuradio/tags.h>
28 
29 namespace gr {
30 
32  {
33  private:
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 
39  public:
40  tag_checker(std::vector<tag_t> &tags):
41  d_has_next_tag(false),
42  d_next_tag_index(0)
43  {
44  d_tags = tags;
45  std::sort(d_tags.begin(), d_tags.end(), &gr::tag_t::offset_compare);
46  if(d_tags.size() > 0) {
47  d_has_next_tag = true;
48  d_next_tag = tags[0];
49  }
50  };
51 
53 
54  void get_tags(std::vector<tag_t> &tag_list, unsigned int offset)
55  {
56  while(d_has_next_tag && (offset >= d_next_tag.offset)) {
57  if(offset == d_next_tag.offset) {
58  tag_list.push_back(d_next_tag);
59  }
60  d_next_tag_index += 1;
61  if(d_next_tag_index >= d_tags.size()) {
62  d_has_next_tag = false;
63  }
64  else {
65  d_next_tag = d_tags[d_next_tag_index];
66  }
67  }
68  };
69 
70  };
71 }
72 
73 #endif /* INCLUDED_GR_RUNTIME_TAG_CHECKER_H */
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:34
void get_tags(std::vector< tag_t > &tag_list, unsigned int offset)
Definition: tag_checker.h:54
Include this header to use the message passing features.
Definition: logger.h:131
~tag_checker()
Definition: tag_checker.h:52
Definition: tag_checker.h:31
tag_checker(std::vector< tag_t > &tags)
Definition: tag_checker.h:40