GNU Radio C++ API Reference g90d26cb
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
pmt_sugar.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2009,2013 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_PMT_SUGAR_H
12#define INCLUDED_PMT_SUGAR_H
13
14/*!
15 * This file is included by pmt.h and contains pseudo-constructor
16 * shorthand for making pmt objects
17 */
18
20#include <string_view>
21
22namespace pmt {
23
24//! Make pmt symbol
25static inline pmt_t mp(std::string_view s) { return string_to_symbol(s); }
26
27//! Make pmt symbol
28static inline pmt_t mp(const char* s) { return string_to_symbol(s); }
29
30//! Make pmt long
31static inline pmt_t mp(long x) { return from_long(x); }
32
33//! Make pmt uint64
34static inline pmt_t mp(long unsigned x) { return from_uint64(x); }
35
36//! Make pmt uint64
37static inline pmt_t mp(long long unsigned x) { return from_uint64(x); }
38
39//! Make pmt long
40static inline pmt_t mp(int x) { return from_long(x); }
41
42//! Make pmt double
43static inline pmt_t mp(double x) { return from_double(x); }
44
45//! Make pmt complex
46static inline pmt_t mp(std::complex<double> z)
47{
48 return make_rectangular(z.real(), z.imag());
49}
50
51//! Make pmt complex
52static inline pmt_t mp(std::complex<float> z)
53{
54 return make_rectangular(z.real(), z.imag());
55}
56
57//! Make pmt msg_accepter
58static inline pmt_t mp(std::shared_ptr<gr::messages::msg_accepter> ma)
59{
60 return make_msg_accepter(ma);
61}
62
63//! Make pmt Binary Large Object (BLOB)
64static inline pmt_t mp(const void* data, size_t len_in_bytes)
65{
66 return make_blob(data, len_in_bytes);
67}
68
69//! Make tuple
70static inline pmt_t mp(const pmt_t& e0) { return make_tuple(e0); }
71
72//! Make tuple
73static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1) { return make_tuple(e0, e1); }
74
75//! Make tuple
76static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2)
77{
78 return make_tuple(e0, e1, e2);
79}
80
81//! Make tuple
82static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3)
83{
84 return make_tuple(e0, e1, e2, e3);
85}
86
87//! Make tuple
88static inline pmt_t
89mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3, const pmt_t& e4)
90{
91 return make_tuple(e0, e1, e2, e3, e4);
92}
93
94//! Make tuple
95static inline pmt_t mp(const pmt_t& e0,
96 const pmt_t& e1,
97 const pmt_t& e2,
98 const pmt_t& e3,
99 const pmt_t& e4,
100 const pmt_t& e5)
101{
102 return make_tuple(e0, e1, e2, e3, e4, e5);
103}
104
105//! Make tuple
106static inline pmt_t mp(const pmt_t& e0,
107 const pmt_t& e1,
108 const pmt_t& e2,
109 const pmt_t& e3,
110 const pmt_t& e4,
111 const pmt_t& e5,
112 const pmt_t& e6)
113{
114 return make_tuple(e0, e1, e2, e3, e4, e5, e6);
115}
116
117//! Make tuple
118static inline pmt_t mp(const pmt_t& e0,
119 const pmt_t& e1,
120 const pmt_t& e2,
121 const pmt_t& e3,
122 const pmt_t& e4,
123 const pmt_t& e5,
124 const pmt_t& e6,
125 const pmt_t& e7)
126{
127 return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
128}
129
130//! Make tuple
131static inline pmt_t mp(const pmt_t& e0,
132 const pmt_t& e1,
133 const pmt_t& e2,
134 const pmt_t& e3,
135 const pmt_t& e4,
136 const pmt_t& e5,
137 const pmt_t& e6,
138 const pmt_t& e7,
139 const pmt_t& e8)
140{
141 return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
142}
143
144//! Make tuple
145static inline pmt_t mp(const pmt_t& e0,
146 const pmt_t& e1,
147 const pmt_t& e2,
148 const pmt_t& e3,
149 const pmt_t& e4,
150 const pmt_t& e5,
151 const pmt_t& e6,
152 const pmt_t& e7,
153 const pmt_t& e8,
154 const pmt_t& e9)
155{
156 return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
157}
158
159
160} /* namespace pmt */
161
162
163#endif /* INCLUDED_PMT_SUGAR_H */
Definition pmt.h:40
PMT_API pmt_t make_rectangular(double re, double im)
Return a complex number constructed of the given real and imaginary parts.
PMT_API pmt_t string_to_symbol(std::string_view s)
Return the symbol whose name is s.
PMT_API pmt_t make_tuple()
PMT_API pmt_t make_msg_accepter(std::shared_ptr< gr::messages::msg_accepter > ma)
make a msg_accepter
static pmt_t mp(std::string_view s)
Make pmt symbol.
Definition pmt_sugar.h:25
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition pmt.h:85
PMT_API pmt_t from_long(long x)
Return the pmt value that represents the integer x.
PMT_API pmt_t make_blob(const void *buf, size_t len)
Make a blob given a pointer and length in bytes.
PMT_API pmt_t from_double(double x)
Return the pmt value that represents double x.
PMT_API pmt_t from_uint64(uint64_t x)
Return the pmt value that represents the uint64 x.