Statistics
| Branch: | Tag: | Revision:

root / gnuradio-core / src / lib / general / gr_annotator_1to1.h @ f914499f

History | View | Annotate | Download (2.3 kB)

1 0952d5a2 Tom Rondeau
/* -*- c++ -*- */
2 0952d5a2 Tom Rondeau
/*
3 0952d5a2 Tom Rondeau
 * Copyright 2010 Free Software Foundation, Inc.
4 0952d5a2 Tom Rondeau
 *
5 0952d5a2 Tom Rondeau
 * This file is part of GNU Radio
6 0952d5a2 Tom Rondeau
 *
7 0952d5a2 Tom Rondeau
 * GNU Radio is free software; you can redistribute it and/or modify
8 0952d5a2 Tom Rondeau
 * it under the terms of the GNU General Public License as published by
9 0952d5a2 Tom Rondeau
 * the Free Software Foundation; either version 3, or (at your option)
10 0952d5a2 Tom Rondeau
 * any later version.
11 0952d5a2 Tom Rondeau
 *
12 0952d5a2 Tom Rondeau
 * GNU Radio is distributed in the hope that it will be useful,
13 0952d5a2 Tom Rondeau
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 0952d5a2 Tom Rondeau
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 0952d5a2 Tom Rondeau
 * GNU General Public License for more details.
16 0952d5a2 Tom Rondeau
 *
17 0952d5a2 Tom Rondeau
 * You should have received a copy of the GNU General Public License
18 0952d5a2 Tom Rondeau
 * along with GNU Radio; see the file COPYING.  If not, write to
19 0952d5a2 Tom Rondeau
 * the Free Software Foundation, Inc., 51 Franklin Street,
20 0952d5a2 Tom Rondeau
 * Boston, MA 02110-1301, USA.
21 0952d5a2 Tom Rondeau
 */
22 0952d5a2 Tom Rondeau
23 0952d5a2 Tom Rondeau
#ifndef INCLUDED_GR_ANNOTATOR_1TO1_H
24 0952d5a2 Tom Rondeau
#define        INCLUDED_GR_ANNOTATOR_1TO1_H
25 0952d5a2 Tom Rondeau
26 f914499f Josh Blum
#include <gr_core_api.h>
27 68b06ac6 Tom Rondeau
#include <gr_sync_block.h>
28 0952d5a2 Tom Rondeau
29 0952d5a2 Tom Rondeau
class gr_annotator_1to1;
30 0952d5a2 Tom Rondeau
typedef boost::shared_ptr<gr_annotator_1to1> gr_annotator_1to1_sptr;
31 0952d5a2 Tom Rondeau
32 0952d5a2 Tom Rondeau
// public constructor
33 f914499f Josh Blum
GR_CORE_API gr_annotator_1to1_sptr 
34 68b06ac6 Tom Rondeau
gr_make_annotator_1to1 (int when, size_t sizeof_stream_item);
35 0952d5a2 Tom Rondeau
36 4a63bc91 Tom Rondeau
/*!
37 4a63bc91 Tom Rondeau
 * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY.
38 4a63bc91 Tom Rondeau
 *
39 4a63bc91 Tom Rondeau
 * This block creates tags to be sent downstream every 10,000 items it sees. The
40 4a63bc91 Tom Rondeau
 * tags contain the name and ID of the instantiated block, use "seq" as a key,
41 4a63bc91 Tom Rondeau
 * and have a counter that increments by 1 for every tag produced that is used
42 4a63bc91 Tom Rondeau
 * as the tag's value. The tags are propagated using the 1-to-1 policy.
43 4a63bc91 Tom Rondeau
 *
44 4a63bc91 Tom Rondeau
 * It also stores a copy of all tags it sees flow past it. These tags can be
45 4a63bc91 Tom Rondeau
 * recalled externally with the data() member.
46 4a63bc91 Tom Rondeau
 *
47 4a63bc91 Tom Rondeau
 * This block is only meant for testing and showing how to use the tags.
48 4a63bc91 Tom Rondeau
 */
49 f914499f Josh Blum
class GR_CORE_API gr_annotator_1to1 : public gr_sync_block
50 0952d5a2 Tom Rondeau
{
51 0952d5a2 Tom Rondeau
 public:
52 0952d5a2 Tom Rondeau
  ~gr_annotator_1to1 ();
53 68b06ac6 Tom Rondeau
  int work (int noutput_items,
54 68b06ac6 Tom Rondeau
            gr_vector_const_void_star &input_items,
55 68b06ac6 Tom Rondeau
            gr_vector_void_star &output_items);
56 4a63bc91 Tom Rondeau
57 4a63bc91 Tom Rondeau
  std::vector<pmt::pmt_t> data() const
58 4a63bc91 Tom Rondeau
  {
59 4a63bc91 Tom Rondeau
    return d_stored_tags;
60 4a63bc91 Tom Rondeau
  }
61 0952d5a2 Tom Rondeau
62 0952d5a2 Tom Rondeau
protected:
63 68b06ac6 Tom Rondeau
  gr_annotator_1to1 (int when, size_t sizeof_stream_item);
64 0952d5a2 Tom Rondeau
65 0952d5a2 Tom Rondeau
 private:
66 0952d5a2 Tom Rondeau
  size_t d_itemsize;
67 11b2b7c4 Tom Rondeau
  uint64_t d_when;
68 0952d5a2 Tom Rondeau
  uint64_t d_tag_counter;
69 4a63bc91 Tom Rondeau
  std::vector<pmt::pmt_t> d_stored_tags;
70 0952d5a2 Tom Rondeau
71 f914499f Josh Blum
  friend GR_CORE_API gr_annotator_1to1_sptr
72 68b06ac6 Tom Rondeau
  gr_make_annotator_1to1 (int when, size_t sizeof_stream_item);
73 0952d5a2 Tom Rondeau
};
74 0952d5a2 Tom Rondeau
75 0952d5a2 Tom Rondeau
#endif