GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
36  mp(const std::string &s)
37  {
38  return string_to_symbol(s);
39  }
40 
41  //! Make pmt symbol
42  static inline pmt_t
43  mp(const char *s)
44  {
45  return string_to_symbol(s);
46  }
47 
48  //! Make pmt long
49  static inline pmt_t
50  mp(long x){
51  return from_long(x);
52  }
53 
54  //! Make pmt uint64
55  static inline pmt_t
56  mp(long unsigned x){
57  return from_uint64(x);
58  }
59 
60  //! Make pmt uint64
61  static inline pmt_t
62  mp(long long unsigned x){
63  return from_uint64(x);
64  }
65 
66  //! Make pmt long
67  static inline pmt_t
68  mp(int x){
69  return from_long(x);
70  }
71 
72  //! Make pmt double
73  static inline pmt_t
74  mp(double x){
75  return from_double(x);
76  }
77 
78  //! Make pmt complex
79  static inline pmt_t
80  mp(std::complex<double> z)
81  {
82  return make_rectangular(z.real(), z.imag());
83  }
84 
85  //! Make pmt complex
86  static inline pmt_t
87  mp(std::complex<float> z)
88  {
89  return make_rectangular(z.real(), z.imag());
90  }
91 
92  //! Make pmt msg_accepter
93  static inline pmt_t
94  mp(boost::shared_ptr<gr::messages::msg_accepter> ma)
95  {
96  return make_msg_accepter(ma);
97  }
98 
99  //! Make pmt Binary Large Object (BLOB)
100  static inline pmt_t
101  mp(const void *data, size_t len_in_bytes)
102  {
103  return make_blob(data, len_in_bytes);
104  }
105 
106  //! Make tuple
107  static inline pmt_t
108  mp(const pmt_t &e0)
109  {
110  return make_tuple(e0);
111  }
112 
113  //! Make tuple
114  static inline pmt_t
115  mp(const pmt_t &e0, const pmt_t &e1)
116  {
117  return make_tuple(e0, e1);
118  }
119 
120  //! Make tuple
121  static inline pmt_t
122  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2)
123  {
124  return make_tuple(e0, e1, e2);
125  }
126 
127  //! Make tuple
128  static inline pmt_t
129  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3)
130  {
131  return make_tuple(e0, e1, e2, e3);
132  }
133 
134  //! Make tuple
135  static inline pmt_t
136  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4)
137  {
138  return make_tuple(e0, e1, e2, e3, e4);
139  }
140 
141  //! Make tuple
142  static inline pmt_t
143  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5)
144  {
145  return make_tuple(e0, e1, e2, e3, e4, e5);
146  }
147 
148  //! Make tuple
149  static inline pmt_t
150  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6)
151  {
152  return make_tuple(e0, e1, e2, e3, e4, e5, e6);
153  }
154 
155  //! Make tuple
156  static inline pmt_t
157  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7)
158  {
159  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
160  }
161 
162  //! Make tuple
163  static inline pmt_t
164  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8)
165  {
166  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
167  }
168 
169  //! Make tuple
170  static inline pmt_t
171  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9)
172  {
173  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
174  }
175 
176 
177 } /* namespace pmt */
178 
179 
180 #endif /* INCLUDED_PMT_SUGAR_H */
PMT_API pmt_t from_long(long x)
Return the pmt value that represents the integer x.
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.
boost::intrusive_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:56
static pmt_t mp(const std::string &s)
Make pmt symbol.
Definition: pmt_sugar.h:36
Definition: pmt.h:51
PMT_API pmt_t make_msg_accepter(boost::shared_ptr< gr::messages::msg_accepter > ma)
make a msg_accepter