GNU Radio 3.6.4 C++ API
gr_feval.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 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 #ifndef INCLUDED_GR_FEVAL_H
23 #define INCLUDED_GR_FEVAL_H
24 
25 #include <gr_core_api.h>
26 #include <gr_complex.h>
27 #include <gruel/pmt.h>
28 
29 /*!
30  * \brief base class for evaluating a function: double -> double
31  * \ingroup misc
32  *
33  * This class is designed to be subclassed in Python or C++
34  * and is callable from both places. It uses SWIG's
35  * "director" feature to implement the magic.
36  * It's slow. Don't use it in a performance critical path.
37  *
38  * Override eval to define the behavior.
39  * Use calleval to invoke eval (this kludge is required to allow a
40  * python specific "shim" to be inserted.
41  */
43 {
44 protected:
45  /*!
46  * \brief override this to define the function
47  */
48  virtual double eval(double x);
49 
50 public:
52  virtual ~gr_feval_dd();
53 
54  virtual double calleval(double x); // invoke "eval"
55 };
56 
57 /*!
58  * \brief base class for evaluating a function: complex -> complex
59  * \ingroup misc
60  *
61  * This class is designed to be subclassed in Python or C++
62  * and is callable from both places. It uses SWIG's
63  * "director" feature to implement the magic.
64  * It's slow. Don't use it in a performance critical path.
65  *
66  * Override eval to define the behavior.
67  * Use calleval to invoke eval (this kludge is required to allow a
68  * python specific "shim" to be inserted.
69  */
71 {
72 protected:
73  /*!
74  * \brief override this to define the function
75  */
76  virtual gr_complex eval(gr_complex x);
77 
78 public:
80  virtual ~gr_feval_cc();
81 
82  virtual gr_complex calleval(gr_complex x); // invoke "eval"
83 };
84 
85 /*!
86  * \brief base class for evaluating a function: long -> long
87  * \ingroup misc
88  *
89  * This class is designed to be subclassed in Python or C++
90  * and is callable from both places. It uses SWIG's
91  * "director" feature to implement the magic.
92  * It's slow. Don't use it in a performance critical path.
93  *
94  * Override eval to define the behavior.
95  * Use calleval to invoke eval (this kludge is required to allow a
96  * python specific "shim" to be inserted.
97  */
99 {
100 protected:
101  /*!
102  * \brief override this to define the function
103  */
104  virtual long eval(long x);
105 
106 public:
108  virtual ~gr_feval_ll();
109 
110  virtual long calleval(long x); // invoke "eval"
111 };
112 
113 /*!
114  * \brief base class for evaluating a function: void -> void
115  * \ingroup misc
116  *
117  * This class is designed to be subclassed in Python or C++
118  * and is callable from both places. It uses SWIG's
119  * "director" feature to implement the magic.
120  * It's slow. Don't use it in a performance critical path.
121  *
122  * Override eval to define the behavior.
123  * Use calleval to invoke eval (this kludge is required to allow a
124  * python specific "shim" to be inserted.
125  */
127 {
128 protected:
129  /*!
130  * \brief override this to define the function
131  */
132  virtual void eval();
133 
134 public:
135  gr_feval() {}
136  virtual ~gr_feval();
137 
138  virtual void calleval(); // invoke "eval"
139 };
140 
141 /*!
142  * \brief base class for evaluating a function: pmt -> void
143  * \ingroup misc
144  *
145  * This class is designed to be subclassed in Python or C++
146  * and is callable from both places. It uses SWIG's
147  * "director" feature to implement the magic.
148  * It's slow. Don't use it in a performance critical path.
149  *
150  * Override eval to define the behavior.
151  * Use calleval to invoke eval (this kludge is required to allow a
152  * python specific "shim" to be inserted.
153  */
155 {
156 protected:
157  /*!
158  * \brief override this to define the function
159  */
160  virtual void eval(pmt::pmt_t x);
161 
162 public:
164  virtual ~gr_feval_p();
165 
166  virtual void calleval(pmt::pmt_t x); // invoke "eval"
167 };
168 
169 /*!
170  * \brief trivial examples / test cases showing C++ calling Python code
171  */
172 GR_CORE_API double gr_feval_dd_example(gr_feval_dd *f, double x);
176 
177 #endif /* INCLUDED_GR_FEVAL_H */