GNU Radio Manual and C++ API Reference  3.8.1.0
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  * 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 along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef INCLUDED_PMT_SUGAR_H
23 #define INCLUDED_PMT_SUGAR_H
24 
25 /*!
26  * This file is included by pmt.h and contains pseudo-constructor
27  * shorthand for making pmt objects
28  */
29 
31 
32 namespace pmt {
33 
34 //! Make pmt symbol
35 static inline pmt_t mp(const std::string& s) { return string_to_symbol(s); }
36 
37 //! Make pmt symbol
38 static inline pmt_t mp(const char* s) { return string_to_symbol(s); }
39 
40 //! Make pmt long
41 static inline pmt_t mp(long x) { return from_long(x); }
42 
43 //! Make pmt uint64
44 static inline pmt_t mp(long unsigned x) { return from_uint64(x); }
45 
46 //! Make pmt uint64
47 static inline pmt_t mp(long long unsigned x) { return from_uint64(x); }
48 
49 //! Make pmt long
50 static inline pmt_t mp(int x) { return from_long(x); }
51 
52 //! Make pmt double
53 static inline pmt_t mp(double x) { return from_double(x); }
54 
55 //! Make pmt complex
56 static inline pmt_t mp(std::complex<double> z)
57 {
58  return make_rectangular(z.real(), z.imag());
59 }
60 
61 //! Make pmt complex
62 static inline pmt_t mp(std::complex<float> z)
63 {
64  return make_rectangular(z.real(), z.imag());
65 }
66 
67 //! Make pmt msg_accepter
68 static inline pmt_t mp(boost::shared_ptr<gr::messages::msg_accepter> ma)
69 {
70  return make_msg_accepter(ma);
71 }
72 
73 //! Make pmt Binary Large Object (BLOB)
74 static inline pmt_t mp(const void* data, size_t len_in_bytes)
75 {
76  return make_blob(data, len_in_bytes);
77 }
78 
79 //! Make tuple
80 static inline pmt_t mp(const pmt_t& e0) { return make_tuple(e0); }
81 
82 //! Make tuple
83 static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1) { return make_tuple(e0, e1); }
84 
85 //! Make tuple
86 static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2)
87 {
88  return make_tuple(e0, e1, e2);
89 }
90 
91 //! Make tuple
92 static inline pmt_t mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3)
93 {
94  return make_tuple(e0, e1, e2, e3);
95 }
96 
97 //! Make tuple
98 static inline pmt_t
99 mp(const pmt_t& e0, const pmt_t& e1, const pmt_t& e2, const pmt_t& e3, const pmt_t& e4)
100 {
101  return make_tuple(e0, e1, e2, e3, e4);
102 }
103 
104 //! Make tuple
105 static 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 {
112  return make_tuple(e0, e1, e2, e3, e4, e5);
113 }
114 
115 //! Make tuple
116 static inline pmt_t mp(const pmt_t& e0,
117  const pmt_t& e1,
118  const pmt_t& e2,
119  const pmt_t& e3,
120  const pmt_t& e4,
121  const pmt_t& e5,
122  const pmt_t& e6)
123 {
124  return make_tuple(e0, e1, e2, e3, e4, e5, e6);
125 }
126 
127 //! Make tuple
128 static inline pmt_t mp(const pmt_t& e0,
129  const pmt_t& e1,
130  const pmt_t& e2,
131  const pmt_t& e3,
132  const pmt_t& e4,
133  const pmt_t& e5,
134  const pmt_t& e6,
135  const pmt_t& e7)
136 {
137  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
138 }
139 
140 //! Make tuple
141 static inline pmt_t mp(const pmt_t& e0,
142  const pmt_t& e1,
143  const pmt_t& e2,
144  const pmt_t& e3,
145  const pmt_t& e4,
146  const pmt_t& e5,
147  const pmt_t& e6,
148  const pmt_t& e7,
149  const pmt_t& e8)
150 {
151  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
152 }
153 
154 //! Make tuple
155 static inline pmt_t mp(const pmt_t& e0,
156  const pmt_t& e1,
157  const pmt_t& e2,
158  const pmt_t& e3,
159  const pmt_t& e4,
160  const pmt_t& e5,
161  const pmt_t& e6,
162  const pmt_t& e7,
163  const pmt_t& e8,
164  const pmt_t& e9)
165 {
166  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
167 }
168 
169 
170 } /* namespace pmt */
171 
172 
173 #endif /* INCLUDED_PMT_SUGAR_H */
PMT_API pmt_t from_long(long x)
Return the pmt value that represents the integer x.
boost::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
Definition: pmt.h:96
PMT_API pmt_t string_to_symbol(const std::string &s)
Return the symbol whose name is s.
PMT_API pmt_t from_uint64(uint64_t x)
Return the pmt value that represents the uint64 x.
PMT_API pmt_t make_tuple()
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_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.
static pmt_t mp(const std::string &s)
Make pmt symbol.
Definition: pmt_sugar.h:35
Definition: pmt.h:51
PMT_API pmt_t make_msg_accepter(boost::shared_ptr< gr::messages::msg_accepter > ma)
make a msg_accepter