GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
stream_demux.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2020 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_BLOCKS_STREAM_DEMUX_H
24 #define INCLUDED_BLOCKS_STREAM_DEMUX_H
25 
26 #include <gnuradio/block.h>
27 #include <gnuradio/blocks/api.h>
28 #include <vector>
29 
30 namespace gr {
31 namespace blocks {
32 
33 /*!
34  * \brief Stream demuxing block to demultiplex one stream into N output streams
35  * \ingroup stream_operators_blk
36  *
37  * \details
38  * Demuxes a stream producing N outputs streams that contains n_0 items in
39  * the first stream, n_1 items in the second, etc. and repeats. Number of
40  * items of each output stream is specified using the 'lengths' parameter
41  * like so [n_0, n_1, ..., n_N-1].
42  *
43  * Example:
44  * lengths = [2, 3, 4]
45  * input stream: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]
46  * output_streams: [0, 1, 9, 10, ...]
47  * [2, 3, 4, 11, ...]
48  * [5, 6, 7, 8, ...]
49  */
50 class BLOCKS_API stream_demux : virtual public gr::block
51 {
52 public:
53  // gr::blocks::stream_demux::sptr
54  typedef std::shared_ptr<stream_demux> sptr;
55 
56  /*!
57  * \brief Stream demuxing block to demultiplex one stream into N output streams
58  *
59  * \param itemsize the item size of the stream
60  * \param lengths a vector (list/tuple) specifying the number of
61  * items to copy to each output stream.
62  *
63  */
64  static sptr make(size_t itemsize, const std::vector<int>& lengths);
65 };
66 
67 } // namespace blocks
68 } // namespace gr
69 
70 #endif /* INCLUDED_BLOCKS_STREAM_DEMUX_H */
The abstract base class for all 'terminal' processing blocks.
Definition: gnuradio-runtime/include/gnuradio/block.h:63
Stream demuxing block to demultiplex one stream into N output streams.
Definition: stream_demux.h:51
std::shared_ptr< stream_demux > sptr
Definition: stream_demux.h:54
static sptr make(size_t itemsize, const std::vector< int > &lengths)
Stream demuxing block to demultiplex one stream into N output streams.
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
GR_RUNTIME_API size_t itemsize(types::vector_type type)
GNU Radio logging wrapper.
Definition: basic_block.h:29