GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
head.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2009,2012,2013 Free Software Foundation, Inc.
4  * Copyright 2021 Marcus Müller
5  *
6  * This file is part of GNU Radio
7  *
8  * SPDX-License-Identifier: GPL-3.0-or-later
9  *
10  */
11 
12 #ifndef INCLUDED_GR_HEAD_H
13 #define INCLUDED_GR_HEAD_H
14 
15 #include <gnuradio/blocks/api.h>
16 #include <gnuradio/sync_block.h>
17 #include <cstddef> // size_t
18 
19 namespace gr {
20 namespace blocks {
21 
22 /*!
23  * \brief stop after processing the first N items
24  * \ingroup misc_blk
25  *
26  * \details
27  * Useful for building test cases, this block consumes only N items from its input, and
28  * copies them to its output, if that is connected.
29  *
30  * You can hence use this block in series with your sample flow if you want a block
31  * downstream of it to be tested with an exact number of input items; or you can put it in
32  * parallel to your data path, so that it stops at most one buffer size after the
33  * specified number of items has been produced upstream.
34  */
35 class BLOCKS_API head : virtual public sync_block
36 {
37 public:
38  // gr::blocks::head::sptr
39  typedef std::shared_ptr<head> sptr;
40 
41  static sptr make(size_t sizeof_stream_item, uint64_t nitems);
42 
43  virtual void reset() = 0;
44  virtual void set_length(uint64_t nitems) = 0;
45 };
46 
47 } /* namespace blocks */
48 } /* namespace gr */
49 
50 #endif /* INCLUDED_GR_HEAD_H */
stop after processing the first N items
Definition: head.h:36
virtual void set_length(uint64_t nitems)=0
static sptr make(size_t sizeof_stream_item, uint64_t nitems)
virtual void reset()=0
std::shared_ptr< head > sptr
Definition: head.h:39
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29