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