GNU Radio 3.7.2 C++ API
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 long
55  static inline pmt_t
56  mp(long long unsigned x){
57  return from_long(x);
58  }
59 
60  //! Make pmt long
61  static inline pmt_t
62  mp(int x){
63  return from_long(x);
64  }
65 
66  //! Make pmt double
67  static inline pmt_t
68  mp(double x){
69  return from_double(x);
70  }
71 
72  //! Make pmt complex
73  static inline pmt_t
74  mp(std::complex<double> z)
75  {
76  return make_rectangular(z.real(), z.imag());
77  }
78 
79  //! Make pmt complex
80  static inline pmt_t
81  mp(std::complex<float> z)
82  {
83  return make_rectangular(z.real(), z.imag());
84  }
85 
86  //! Make pmt msg_accepter
87  static inline pmt_t
89  {
90  return make_msg_accepter(ma);
91  }
92 
93  //! Make pmt Binary Large Object (BLOB)
94  static inline pmt_t
95  mp(const void *data, size_t len_in_bytes)
96  {
97  return make_blob(data, len_in_bytes);
98  }
99 
100  //! Make tuple
101  static inline pmt_t
102  mp(const pmt_t &e0)
103  {
104  return make_tuple(e0);
105  }
106 
107  //! Make tuple
108  static inline pmt_t
109  mp(const pmt_t &e0, const pmt_t &e1)
110  {
111  return make_tuple(e0, e1);
112  }
113 
114  //! Make tuple
115  static inline pmt_t
116  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2)
117  {
118  return make_tuple(e0, e1, e2);
119  }
120 
121  //! Make tuple
122  static inline pmt_t
123  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3)
124  {
125  return make_tuple(e0, e1, e2, e3);
126  }
127 
128  //! Make tuple
129  static inline pmt_t
130  mp(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4)
131  {
132  return make_tuple(e0, e1, e2, e3, e4);
133  }
134 
135  //! Make tuple
136  static inline pmt_t
137  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)
138  {
139  return make_tuple(e0, e1, e2, e3, e4, e5);
140  }
141 
142  //! Make tuple
143  static inline pmt_t
144  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)
145  {
146  return make_tuple(e0, e1, e2, e3, e4, e5, e6);
147  }
148 
149  //! Make tuple
150  static inline pmt_t
151  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)
152  {
153  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7);
154  }
155 
156  //! Make tuple
157  static inline pmt_t
158  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)
159  {
160  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8);
161  }
162 
163  //! Make tuple
164  static inline pmt_t
165  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)
166  {
167  return make_tuple(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9);
168  }
169 
170 
171 } /* namespace pmt */
172 
173 
174 #endif /* INCLUDED_PMT_SUGAR_H */
PMT_API pmt_t from_long(long x)
Return the pmt value that represents the integer x.
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
PMT_API pmt_t string_to_symbol(const std::string &s)
Return the symbol whose name is s.
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
PMT_API pmt_t make_msg_accepter(boost::shared_ptr< gr::messages::msg_accepter > ma)
make a msg_accepter