GNU Radio 3.6.5.1 C++ API
gr_tag_debug.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 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_TAG_DEBUG_H
24 #define INCLUDED_GR_TAG_DEBUG_H
25 
26 #include <gr_core_api.h>
27 #include <gr_sync_block.h>
28 #include <gruel/thread.h>
29 #include <stddef.h>
30 
31 class gr_tag_debug;
33 
35 gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name);
36 
37 /*!
38  * \brief Bit bucket that prints out any tag received.
39  *
40  * This block collects all tags sent to it on all input ports and
41  * displays them to stdout in a formatted way. The \p name parameter
42  * is used to identify which debug sink generated the tag, so when
43  * connecting a block to this debug sink, an appropriate name is
44  * something that identifies the input block.
45  *
46  * This block otherwise acts as a NULL sink in that items from the
47  * input stream are ignored. It is designed to be able to attach to
48  * any block and watch all tags streaming out of that block for
49  * debugging purposes.
50  *
51  * The tags from the last call to this work function are stored and
52  * can be retrieved using the function 'current_tags'.
53  */
55 {
56  private:
58  gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name);
59  gr_tag_debug(size_t sizeof_stream_item, const std::string &name);
60 
61  std::string d_name;
62  std::vector<gr_tag_t> d_tags;
63  std::vector<gr_tag_t>::iterator d_tags_itr;
64  bool d_display;
65  gruel::mutex d_mutex;
66 
67  public:
68  /*!
69  * \brief Returns a vector of gr_tag_t items as of the last call to
70  * work.
71  */
72  std::vector<gr_tag_t> current_tags();
73 
74  /*!
75  * \brief Set the display of tags to stdout on/off.
76  */
77  void set_display(bool d);
78 
79  int work(int noutput_items,
80  gr_vector_const_void_star &input_items,
81  gr_vector_void_star &output_items);
82 };
83 
84 #endif /* INCLUDED_GR_TAG_DEBUG_H */