Imported Upstream version 3.0
[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 2, 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 class gr_feval_dd
36 {
37 public:
38   gr_feval_dd() {}
39   virtual ~gr_feval_dd();
40
41   /*!
42    * \brief override this to define the function
43    */
44   virtual double eval(double x);
45 };
46
47 /*!
48  * \brief base class for evaluating a function: complex -> complex
49  *
50  * This class is designed to be subclassed in Python or C++
51  * and is callable from both places.  It uses SWIG's
52  * "director" feature to implement the magic.
53  * It's slow. Don't use it in a performance critical path.
54  */
55 class gr_feval_cc
56 {
57 public:
58   gr_feval_cc() {}
59   virtual ~gr_feval_cc();
60
61   /*!
62    * \brief override this to define the function
63    */
64   virtual gr_complex eval(gr_complex x);
65 };
66
67 /*!
68  * \brief base class for evaluating a function: long -> long
69  *
70  * This class is designed to be subclassed in Python or C++
71  * and is callable from both places.  It uses SWIG's
72  * "director" feature to implement the magic.
73  * It's slow. Don't use it in a performance critical path.
74  */
75 class gr_feval_ll
76 {
77 public:
78   gr_feval_ll() {}
79   virtual ~gr_feval_ll();
80
81   /*!
82    * \brief override this to define the function
83    */
84   virtual long eval(long x);
85 };
86
87 /*!
88  * \brief trivial examples / test cases showing C++ calling Python code
89  */
90 double     gr_feval_dd_example(gr_feval_dd *f, double x);
91 gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x);
92 long       gr_feval_ll_example(gr_feval_ll *f, long x);
93
94
95 #endif /* INCLUDED_GR_FEVAL_H */