Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_feval.h
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_complex.h>
26
27 /*!
28  * \brief base class for evaluating a function: double -> double
29  * \ingroup misc
30  *
31  * This class is designed to be subclassed in Python or C++
32  * and is callable from both places.  It uses SWIG's
33  * "director" feature to implement the magic.
34  * It's slow. Don't use it in a performance critical path.
35  *
36  * Override eval to define the behavior.
37  * Use calleval to invoke eval (this kludge is required to allow a
38  * python specific "shim" to be inserted.
39  */
40 class gr_feval_dd
41 {
42 protected:
43   /*!
44    * \brief override this to define the function
45    */
46   virtual double eval(double x);
47
48 public:
49   gr_feval_dd() {}
50   virtual ~gr_feval_dd();
51
52   virtual double calleval(double x);    // invoke "eval"
53 };
54
55 /*!
56  * \brief base class for evaluating a function: complex -> complex
57  * \ingroup misc
58  *
59  * This class is designed to be subclassed in Python or C++
60  * and is callable from both places.  It uses SWIG's
61  * "director" feature to implement the magic.
62  * It's slow. Don't use it in a performance critical path.
63  *
64  * Override eval to define the behavior.
65  * Use calleval to invoke eval (this kludge is required to allow a
66  * python specific "shim" to be inserted.
67  */
68 class gr_feval_cc
69 {
70 protected:
71   /*!
72    * \brief override this to define the function
73    */
74   virtual gr_complex eval(gr_complex x);
75   
76 public:
77   gr_feval_cc() {}
78   virtual ~gr_feval_cc();
79
80   virtual gr_complex calleval(gr_complex x);    // invoke "eval"
81 };
82
83 /*!
84  * \brief base class for evaluating a function: long -> long
85  * \ingroup misc
86  *
87  * This class is designed to be subclassed in Python or C++
88  * and is callable from both places.  It uses SWIG's
89  * "director" feature to implement the magic.
90  * It's slow. Don't use it in a performance critical path.
91  *
92  * Override eval to define the behavior.
93  * Use calleval to invoke eval (this kludge is required to allow a
94  * python specific "shim" to be inserted.
95  */
96 class gr_feval_ll
97 {
98 protected:
99   /*!
100    * \brief override this to define the function
101    */
102   virtual long eval(long x);
103
104 public:
105   gr_feval_ll() {}
106   virtual ~gr_feval_ll();
107
108   virtual long calleval(long x);        // invoke "eval"
109 };
110
111 /*!
112  * \brief base class for evaluating a function: void -> void
113  * \ingroup misc
114  *
115  * This class is designed to be subclassed in Python or C++
116  * and is callable from both places.  It uses SWIG's
117  * "director" feature to implement the magic.
118  * It's slow. Don't use it in a performance critical path.
119  *
120  * Override eval to define the behavior.
121  * Use calleval to invoke eval (this kludge is required to allow a
122  * python specific "shim" to be inserted.
123  */
124 class gr_feval
125 {
126 protected:
127   /*!
128    * \brief override this to define the function
129    */
130   virtual void eval();
131
132 public:
133   gr_feval() {}
134   virtual ~gr_feval();
135
136   virtual void calleval();      // invoke "eval"
137 };
138
139 /*!
140  * \brief trivial examples / test cases showing C++ calling Python code
141  */
142 double     gr_feval_dd_example(gr_feval_dd *f, double x);
143 gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x);
144 long       gr_feval_ll_example(gr_feval_ll *f, long x);
145 void       gr_feval_example(gr_feval *f);
146
147 #endif /* INCLUDED_GR_FEVAL_H */