GNU Radio Manual and C++ API Reference 3.10.5.1
The Free & Open Software Radio Ecosystem
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
21namespace pmt {
22
23//! Make pmt symbol
24static inline pmt_t mp(const std::string& s) { return string_to_symbol(s); }
25
26//! Make pmt symbol
27static inline pmt_t mp(const char* s) { return string_to_symbol(s); }
28
29//! Make pmt long
30static inline pmt_t mp(long x) { return from_long(x); }
31
32//! Make pmt uint64
33static inline pmt_t mp(long unsigned x) { return from_uint64(x); }
34
35//! Make pmt uint64
36static inline pmt_t mp(long long unsigned x) { return from_uint64(x); }
37
38//! Make pmt long
39static inline pmt_t mp(int x) { return from_long(x); }
40
41//! Make pmt double
42static inline pmt_t mp(double x) { return from_double(x); }
43
44//! Make pmt complex
45static inline pmt_t mp(std::complex<double> z)
46{
47 return make_rectangular(z.real(), z.imag());
48}
49
50//! Make pmt complex
51static inline pmt_t mp(std::complex<float> z)
52{
53 return make_rectangular(z.real(), z.imag());
54}
55
56//! Make pmt msg_accepter
57static inline pmt_t mp(std::shared_ptr<gr::messages::msg_accepter> ma)
58{
59 return make_msg_accepter(ma);
60}
61
62//! Make pmt Binary Large Object (BLOB)
63static inline pmt_t mp(const void* data, size_t len_in_bytes)
64{
65 return make_blob(data, len_in_bytes);
66}
67
68//! Make tuple
69static inline pmt_t mp(const pmt_t& e0) { return make_tuple(e0); }
70
71//! Make tuple
72static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1) { return make_tuple(e0, e1); }
73
74//! Make tuple
75static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2)
76{
77 return make_tuple(e0, e1, e2);
78}
79
80//! Make tuple
81static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3)
82{
83 return make_tuple(e0, e1, e2, e3);
84}
85
86//! Make tuple
87static inline pmt_t
88mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3, const pmt_t& e4)
89{
90 return make_tuple(e0, e1, e2, e3, e4);
91}
92
93//! Make tuple
94static inline pmt_t mp(const pmt_t& e0,
95 const pmt_t& e1,
96 const pmt_t& e2,
97 const pmt_t& e3,
98 const pmt_t& e4,
99 const pmt_t& e5)
100{
101 return make_tuple(e0, e1, e2, e3, e4, e5);
102}
103
104//! Make tuple
105static inline pmt_t mp(const pmt_t& e0,
106 const pmt_t& e1,
107 const pmt_t& e2,
108 const pmt_t& e3,
109 const pmt_t& e4,
110 const pmt_t& e5,
111 const pmt_t& e6)
112{
113 return make_tuple(e0, e1, e2, e3, e4, e5, e6);
114}
115
116//! Make tuple
117static inline pmt_t mp(const pmt_t& e0,
118 const pmt_t& e1,
119 const pmt_t& e2,
120 const pmt_t& e3,
121 const pmt_t& e4,
122 const pmt_t& e5,
123 const pmt_t& e6,
124 const pmt_t& e7)
125{
126 return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
127}
128
129//! Make tuple
130static inline pmt_t mp(const pmt_t& e0,
131 const pmt_t& e1,
132 const pmt_t& e2,
133 const pmt_t& e3,
134 const pmt_t& e4,
135 const pmt_t& e5,
136 const pmt_t& e6,
137 const pmt_t& e7,
138 const pmt_t& e8)
139{
140 return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
141}
142
143//! Make tuple
144static inline pmt_t mp(const pmt_t& e0,
145 const pmt_t& e1,
146 const pmt_t& e2,
147 const pmt_t& e3,
148 const pmt_t& e4,
149 const pmt_t& e5,
150 const pmt_t& e6,
151 const pmt_t& e7,
152 const pmt_t& e8,
153 const pmt_t& e9)
154{
155 return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
156}
157
158
159} /* namespace pmt */
160
161
162#endif /* INCLUDED_PMT_SUGAR_H */
Definition: pmt.h:38
PMT_API pmt_t string_to_symbol(const std::string &s)
Return the symbol whose name is s.
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 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(const std::string &s)
Make pmt symbol.
Definition: pmt_sugar.h:24
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83
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.