GNU Radio Manual and C++ API Reference  3.10.7.0
The Free & Open Software Radio Ecosystem
io_signature.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2007 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef INCLUDED_IO_SIGNATURE_H
12 #define INCLUDED_IO_SIGNATURE_H
13 
14 // For testing purposes, force single mapped buffers to make all QA use them
15 //#define FORCE_SINGLE_MAPPED
16 
17 #include <functional>
18 
19 #include <gnuradio/api.h>
20 #ifdef FORCE_SINGLE_MAPPED
21 #include <gnuradio/host_buffer.h>
22 #else
24 #endif
25 #include <gnuradio/buffer_type.h>
26 #include <gnuradio/runtime_types.h>
27 
28 namespace gr {
29 
30 /*!
31  * \brief i/o signature for input and output ports.
32  * \brief misc
33  */
35 {
36  int d_min_streams;
37  int d_max_streams;
38  std::vector<int> d_sizeof_stream_item;
39  gr_vector_buffer_type d_stream_buffer_type;
40 
41  io_signature(int min_streams,
42  int max_streams,
43  const std::vector<int>& sizeof_stream_items,
44  gr_vector_buffer_type buftypes);
45 
46 public:
47  typedef std::shared_ptr<io_signature> sptr;
48 
49  static constexpr int IO_INFINITE = -1;
50 
51  ~io_signature();
52 
53  /*!
54  * \brief Create an i/o signature
55  *
56  * \ingroup internal
57  * \param min_streams specify minimum number of streams (>= 0)
58  * \param max_streams specify maximum number of streams (>= min_streams or -1 ->
59  * infinite) \param sizeof_stream_item specify the size of the items in each stream
60  * \param buftype type of buffers the streams should use (defaults to standard host
61  * double mapped buffer)
62  */
63  static sptr make(int min_streams,
64  int max_streams,
65  int sizeof_stream_item,
66 #ifdef FORCE_SINGLE_MAPPED
68 #else
70 #endif
71 
72  /*!
73  * \brief Create an i/o signature
74  *
75  * \param min_streams specify minimum number of streams (>= 0)
76  * \param max_streams specify maximum number of streams (>= min_streams or -1 ->
77  * infinite) \param sizeof_stream_item1 specify the size of the items in the first
78  * stream \param sizeof_stream_item2 specify the size of the items in the second and
79  * subsequent streams
80  * \param buftype1 type of buffers the first stream should use (defaults to standard
81  * host double mapped buffer)
82  * \param buftype2 type of buffers the second and subsequent streams should use
83  * (defaults to standard host double mapped buffer)
84  */
85  static sptr make2(int min_streams,
86  int max_streams,
87  int sizeof_stream_item1,
88  int sizeof_stream_item2,
89 #ifdef FORCE_SINGLE_MAPPED
90  buffer_type buftype1 = host_buffer::type,
91  buffer_type buftype2 = host_buffer::type);
92 #else
95 #endif
96 
97  /*!
98  * \brief Create an i/o signature
99  *
100  * \param min_streams specify minimum number of streams (>= 0)
101  * \param max_streams specify maximum number of streams (>= min_streams or -1 ->
102  * infinite) \param sizeof_stream_item1 specify the size of the items in the first
103  * stream \param sizeof_stream_item2 specify the size of the items in the second
104  * stream \param sizeof_stream_item3 specify the size of the items in the third and
105  * subsequent streams
106  * \param buftype1 type of buffers the first stream should use (defaults to standard
107  * host double mapped buffer)
108  * \param buftype2 type of buffers the second stream should use (defaults to standard
109  * host double mapped buffer)
110  * \param buftype3 type of buffers the third and subsequent streams should use
111  * (defaults to standard host double mapped buffer)
112  */
113  static sptr make3(int min_streams,
114  int max_streams,
115  int sizeof_stream_item1,
116  int sizeof_stream_item2,
117  int sizeof_stream_item3,
118 #ifdef FORCE_SINGLE_MAPPED
119  buffer_type buftype1 = host_buffer::type,
120  buffer_type buftype2 = host_buffer::type,
121  buffer_type buftype3 = host_buffer::type);
122 #else
126 #endif
127 
128  /*!
129  * \brief Create an i/o signature
130  *
131  * \param min_streams specify minimum number of streams (>= 0)
132  * \param max_streams specify maximum number of streams (>= min_streams or -1 ->
133  * infinite) \param sizeof_stream_items specify the size of the items in the streams
134  *
135  * If there are more streams than there are entries in
136  * sizeof_stream_items, the value of the last entry in
137  * sizeof_stream_items is used for the missing values.
138  * sizeof_stream_items must contain at least 1 entry.
139  */
140  static sptr
141  makev(int min_streams, int max_streams, const std::vector<int>& sizeof_stream_items);
142 
143  /*!
144  * \brief Create an i/o signature
145  *
146  * \param min_streams specify minimum number of streams (>= 0)
147  * \param max_streams specify maximum number of streams (>= min_streams or -1 ->
148  * infinite)
149  * \param sizeof_stream_items specify the size of the items in the streams
150  * \param buftypes the type of buffer each stream will should use
151  *
152  * If there are more streams than there are entries in
153  * sizeof_stream_items, the value of the last entry in
154  * sizeof_stream_items is used for the missing values.
155  * sizeof_stream_items must contain at least 1 entry.
156  */
157  static sptr makev(int min_streams,
158  int max_streams,
159  const std::vector<int>& sizeof_stream_items,
160  gr_vector_buffer_type buftypes);
161 
162  int min_streams() const { return d_min_streams; }
163  int max_streams() const { return d_max_streams; }
164  int sizeof_stream_item(int index) const;
165  std::vector<int> sizeof_stream_items() const;
166  buffer_type stream_buffer_type(size_t index) const;
167  gr_vector_buffer_type stream_buffer_types() const;
168 };
169 
170 } /* namespace gr */
171 
172 #endif /* INCLUDED_IO_SIGNATURE_H */
static buffer_type type
Definition: buffer_double_mapped.h:31
std::shared_ptr< io_signature > sptr
Definition: io_signature.h:47
int max_streams() const
Definition: io_signature.h:163
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:18
int min_streams() const
Definition: io_signature.h:162
GNU Radio logging wrapper.
Definition: basic_block.h:29
Template used to create buffer types. Note that the factory_class parameter must contain a static fun...
Definition: buffer_type.h:96
i/o signature for input and output ports.
Definition: io_signature.h:34
Base class for describing a buffer&#39;s type.
Definition: buffer_type.h:29
std::vector< std::reference_wrapper< const buffer_type_base > > gr_vector_buffer_type
Definition: buffer_type.h:88
static buffer_type type
Definition: host_buffer.h:24