GNU Radio Manual and C++ API Reference  3.7.13.4
The Free & Open Software Radio Ecosystem
feval.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,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
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_FEVAL_H
24 #define INCLUDED_GR_FEVAL_H
25 
26 #include <gnuradio/api.h>
27 #include <gnuradio/gr_complex.h>
28 #include <pmt/pmt.h>
29 
30 namespace gr {
31 
32  /*!
33  * \brief base class for evaluating a function: double -> double
34  * \ingroup misc
35  *
36  * This class is designed to be subclassed in Python or C++ and is
37  * callable from both places. It uses SWIG's "director" feature to
38  * implement the magic.
39  *
40  * It's slow. Don't use it in a performance critical path.
41  *
42  * Override eval to define the behavior.
43  * Use calleval to invoke eval (this kludge is required to allow a
44  * python specific "shim" to be inserted.
45  */
47  {
48  protected:
49  /*!
50  * \brief override this to define the function
51  */
52  virtual double eval(double x);
53 
54  public:
55  feval_dd() {}
56  virtual ~feval_dd();
57 
58  virtual double calleval(double x); // invoke "eval"
59  };
60 
61  /*!
62  * \brief base class for evaluating a function: complex -> complex
63  * \ingroup misc
64  *
65  * This class is designed to be subclassed in Python or C++ and is
66  * callable from both places. It uses SWIG's "director" feature to
67  * implement the magic.
68  *
69  * It's slow. Don't use it in a performance critical path.
70  *
71  * Override eval to define the behavior.
72  * Use calleval to invoke eval (this kludge is required to allow a
73  * python specific "shim" to be inserted.
74  */
76  {
77  protected:
78  /*!
79  * \brief override this to define the function
80  */
81  virtual gr_complex eval(gr_complex x);
82 
83  public:
84  feval_cc() {}
85  virtual ~feval_cc();
86 
87  virtual gr_complex calleval(gr_complex x); // invoke "eval"
88  };
89 
90  /*!
91  * \brief base class for evaluating a function: long -> long
92  * \ingroup misc
93  *
94  * This class is designed to be subclassed in Python or C++ and is
95  * callable from both places. It uses SWIG's "director" feature to
96  * implement the magic.
97  *
98  * It's slow. Don't use it in a performance critical path.
99  *
100  * Override eval to define the behavior.
101  * Use calleval to invoke eval (this kludge is required to allow a
102  * python specific "shim" to be inserted.
103  */
105  {
106  protected:
107  /*!
108  * \brief override this to define the function
109  */
110  virtual long eval(long x);
111 
112  public:
113  feval_ll() {}
114  virtual ~feval_ll();
115 
116  virtual long calleval(long x); // invoke "eval"
117  };
118 
119  /*!
120  * \brief base class for evaluating a function: void -> void
121  * \ingroup misc
122  *
123  * This class is designed to be subclassed in Python or C++ and is
124  * callable from both places. It uses SWIG's "director" feature to
125  * implement the magic.
126  *
127  * It's slow. Don't use it in a performance critical path.
128  *
129  * Override eval to define the behavior.
130  * Use calleval to invoke eval (this kludge is required to allow a
131  * python specific "shim" to be inserted.
132  */
134  {
135  protected:
136  /*!
137  * \brief override this to define the function
138  */
139  virtual void eval();
140 
141  public:
142  feval() {}
143  virtual ~feval();
144 
145  virtual void calleval(); // invoke "eval"
146  };
147 
148  /*!
149  * \brief base class for evaluating a function: pmt -> void
150  * \ingroup misc
151  *
152  * This class is designed to be subclassed in Python or C++ and is
153  * callable from both places. It uses SWIG's "director" feature to
154  * implement the magic.
155  *
156  * It's slow. Don't use it in a performance critical path.
157  *
158  * Override eval to define the behavior.
159  * Use calleval to invoke eval (this kludge is required to allow a
160  * python specific "shim" to be inserted.
161  */
163  {
164  protected:
165  /*!
166  * \brief override this to define the function
167  */
168  virtual void eval(pmt::pmt_t x);
169 
170  public:
171  feval_p() {}
172  virtual ~feval_p();
173 
174  virtual void calleval(pmt::pmt_t x); // invoke "eval"
175  };
176 
177  /*!
178  * \brief trivial examples / test cases showing C++ calling Python code
179  */
180  GR_RUNTIME_API double feval_dd_example(feval_dd *f, double x);
182  GR_RUNTIME_API long feval_ll_example(feval_ll *f, long x);
184 
185 } /* namespace gr */
186 
187 #endif /* INCLUDED_GR_FEVAL_H */
GR_RUNTIME_API double feval_dd_example(feval_dd *f, double x)
trivial examples / test cases showing C++ calling Python code
feval()
Definition: feval.h:142
feval_p()
Definition: feval.h:171
base class for evaluating a function: long -> longThis class is designed to be subclassed in Python o...
Definition: feval.h:104
GR_RUNTIME_API long feval_ll_example(feval_ll *f, long x)
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
std::complex< float > gr_complex
Definition: gr_complex.h:27
Include this header to use the message passing features.
Definition: logger.h:695
base class for evaluating a function: void -> voidThis class is designed to be subclassed in Python o...
Definition: feval.h:133
GR_RUNTIME_API gr_complex feval_cc_example(feval_cc *f, gr_complex x)
feval_ll()
Definition: feval.h:113
base class for evaluating a function: complex -> complexThis class is designed to be subclassed in Py...
Definition: feval.h:75
base class for evaluating a function: double -> doubleThis class is designed to be subclassed in Pyth...
Definition: feval.h:46
base class for evaluating a function: pmt -> voidThis class is designed to be subclassed in Python or...
Definition: feval.h:162
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
feval_cc()
Definition: feval.h:84
GR_RUNTIME_API void feval_example(feval *f)
feval_dd()
Definition: feval.h:55