GNU Radio 3.5.3.2 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2006 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 #ifndef INCLUDED_GR_FEVAL_H 00023 #define INCLUDED_GR_FEVAL_H 00024 00025 #include <gr_core_api.h> 00026 #include <gr_complex.h> 00027 00028 /*! 00029 * \brief base class for evaluating a function: double -> double 00030 * \ingroup misc 00031 * 00032 * This class is designed to be subclassed in Python or C++ 00033 * and is callable from both places. It uses SWIG's 00034 * "director" feature to implement the magic. 00035 * It's slow. Don't use it in a performance critical path. 00036 * 00037 * Override eval to define the behavior. 00038 * Use calleval to invoke eval (this kludge is required to allow a 00039 * python specific "shim" to be inserted. 00040 */ 00041 class GR_CORE_API gr_feval_dd 00042 { 00043 protected: 00044 /*! 00045 * \brief override this to define the function 00046 */ 00047 virtual double eval(double x); 00048 00049 public: 00050 gr_feval_dd() {} 00051 virtual ~gr_feval_dd(); 00052 00053 virtual double calleval(double x); // invoke "eval" 00054 }; 00055 00056 /*! 00057 * \brief base class for evaluating a function: complex -> complex 00058 * \ingroup misc 00059 * 00060 * This class is designed to be subclassed in Python or C++ 00061 * and is callable from both places. It uses SWIG's 00062 * "director" feature to implement the magic. 00063 * It's slow. Don't use it in a performance critical path. 00064 * 00065 * Override eval to define the behavior. 00066 * Use calleval to invoke eval (this kludge is required to allow a 00067 * python specific "shim" to be inserted. 00068 */ 00069 class GR_CORE_API gr_feval_cc 00070 { 00071 protected: 00072 /*! 00073 * \brief override this to define the function 00074 */ 00075 virtual gr_complex eval(gr_complex x); 00076 00077 public: 00078 gr_feval_cc() {} 00079 virtual ~gr_feval_cc(); 00080 00081 virtual gr_complex calleval(gr_complex x); // invoke "eval" 00082 }; 00083 00084 /*! 00085 * \brief base class for evaluating a function: long -> long 00086 * \ingroup misc 00087 * 00088 * This class is designed to be subclassed in Python or C++ 00089 * and is callable from both places. It uses SWIG's 00090 * "director" feature to implement the magic. 00091 * It's slow. Don't use it in a performance critical path. 00092 * 00093 * Override eval to define the behavior. 00094 * Use calleval to invoke eval (this kludge is required to allow a 00095 * python specific "shim" to be inserted. 00096 */ 00097 class GR_CORE_API gr_feval_ll 00098 { 00099 protected: 00100 /*! 00101 * \brief override this to define the function 00102 */ 00103 virtual long eval(long x); 00104 00105 public: 00106 gr_feval_ll() {} 00107 virtual ~gr_feval_ll(); 00108 00109 virtual long calleval(long x); // invoke "eval" 00110 }; 00111 00112 /*! 00113 * \brief base class for evaluating a function: void -> void 00114 * \ingroup misc 00115 * 00116 * This class is designed to be subclassed in Python or C++ 00117 * and is callable from both places. It uses SWIG's 00118 * "director" feature to implement the magic. 00119 * It's slow. Don't use it in a performance critical path. 00120 * 00121 * Override eval to define the behavior. 00122 * Use calleval to invoke eval (this kludge is required to allow a 00123 * python specific "shim" to be inserted. 00124 */ 00125 class GR_CORE_API gr_feval 00126 { 00127 protected: 00128 /*! 00129 * \brief override this to define the function 00130 */ 00131 virtual void eval(); 00132 00133 public: 00134 gr_feval() {} 00135 virtual ~gr_feval(); 00136 00137 virtual void calleval(); // invoke "eval" 00138 }; 00139 00140 /*! 00141 * \brief trivial examples / test cases showing C++ calling Python code 00142 */ 00143 GR_CORE_API double gr_feval_dd_example(gr_feval_dd *f, double x); 00144 GR_CORE_API gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x); 00145 GR_CORE_API long gr_feval_ll_example(gr_feval_ll *f, long x); 00146 GR_CORE_API void gr_feval_example(gr_feval *f); 00147 00148 #endif /* INCLUDED_GR_FEVAL_H */