]> git.gag.com Git - debian/gnuradio/blob - gruel/src/include/gruel/pmt_sugar.h
Add blobs and shorthand pmt pseudo-constructors.
[debian/gnuradio] / gruel / src / include / gruel / pmt_sugar.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 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 #ifndef INCLUDED_GRUEL_PMT_SUGAR_H
22 #define INCLUDED_GRUEL_PMT_SUGAR_H
23
24 /*!
25  * This file is included by pmt.h and contains pseudo-constructor
26  * shorthand for making pmt objects
27  */
28
29 namespace pmt {
30
31   //! Make pmt symbol
32   static inline pmt_t
33   mp(const std::string &s)
34   {
35     return pmt_string_to_symbol(s);
36   }
37
38   //! Make pmt symbol
39   static inline pmt_t
40   mp(const char *s)
41   {
42     return pmt_string_to_symbol(s);
43   }
44
45   //! Make pmt long
46   static inline pmt_t
47   mp(long x){
48     return pmt_from_long(x);
49   }
50
51   //! Make pmt long
52   static inline pmt_t
53   mp(int x){
54     return pmt_from_long(x);
55   }
56
57   //! Make pmt double
58   static inline pmt_t
59   mp(double x){
60     return pmt_from_double(x);
61   }
62   
63   //! Make pmt complex
64   static inline pmt_t
65   mp(std::complex<double> z)
66   {
67     return pmt_make_rectangular(z.real(), z.imag());
68   }
69
70   //! Make pmt complex
71   static inline pmt_t
72   mp(std::complex<float> z)
73   {
74     return pmt_make_rectangular(z.real(), z.imag());
75   }
76
77   //! Make pmt msg_accepter
78   static inline pmt_t
79   mp(boost::shared_ptr<gruel::msg_accepter> ma)
80   {
81     return pmt_make_msg_accepter(ma);
82   }
83
84   //! Make pmt Binary Large Object (BLOB)
85   static inline pmt_t
86   mp(const void *data, size_t len_in_bytes)
87   {
88     return pmt_make_blob(data, len_in_bytes);
89   }
90
91 } /* namespace pmt */
92
93
94 #endif /* INCLUDED_GRUEL_PMT_SUGAR_H */