GNU Radio 3.6.5 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 #include <gruel/pmt.h> 00028 00029 /*! 00030 * \brief base class for evaluating a function: double -> double 00031 * \ingroup misc 00032 * 00033 * This class is designed to be subclassed in Python or C++ 00034 * and is callable from both places. It uses SWIG's 00035 * "director" feature to implement the magic. 00036 * It's slow. Don't use it in a performance critical path. 00037 * 00038 * Override eval to define the behavior. 00039 * Use calleval to invoke eval (this kludge is required to allow a 00040 * python specific "shim" to be inserted. 00041 */ 00042 class GR_CORE_API gr_feval_dd 00043 { 00044 protected: 00045 /*! 00046 * \brief override this to define the function 00047 */ 00048 virtual double eval(double x); 00049 00050 public: 00051 gr_feval_dd() {} 00052 virtual ~gr_feval_dd(); 00053 00054 virtual double calleval(double x); // invoke "eval" 00055 }; 00056 00057 /*! 00058 * \brief base class for evaluating a function: complex -> complex 00059 * \ingroup misc 00060 * 00061 * This class is designed to be subclassed in Python or C++ 00062 * and is callable from both places. It uses SWIG's 00063 * "director" feature to implement the magic. 00064 * It's slow. Don't use it in a performance critical path. 00065 * 00066 * Override eval to define the behavior. 00067 * Use calleval to invoke eval (this kludge is required to allow a 00068 * python specific "shim" to be inserted. 00069 */ 00070 class GR_CORE_API gr_feval_cc 00071 { 00072 protected: 00073 /*! 00074 * \brief override this to define the function 00075 */ 00076 virtual gr_complex eval(gr_complex x); 00077 00078 public: 00079 gr_feval_cc() {} 00080 virtual ~gr_feval_cc(); 00081 00082 virtual gr_complex calleval(gr_complex x); // invoke "eval" 00083 }; 00084 00085 /*! 00086 * \brief base class for evaluating a function: long -> long 00087 * \ingroup misc 00088 * 00089 * This class is designed to be subclassed in Python or C++ 00090 * and is callable from both places. It uses SWIG's 00091 * "director" feature to implement the magic. 00092 * It's slow. Don't use it in a performance critical path. 00093 * 00094 * Override eval to define the behavior. 00095 * Use calleval to invoke eval (this kludge is required to allow a 00096 * python specific "shim" to be inserted. 00097 */ 00098 class GR_CORE_API gr_feval_ll 00099 { 00100 protected: 00101 /*! 00102 * \brief override this to define the function 00103 */ 00104 virtual long eval(long x); 00105 00106 public: 00107 gr_feval_ll() {} 00108 virtual ~gr_feval_ll(); 00109 00110 virtual long calleval(long x); // invoke "eval" 00111 }; 00112 00113 /*! 00114 * \brief base class for evaluating a function: void -> void 00115 * \ingroup misc 00116 * 00117 * This class is designed to be subclassed in Python or C++ 00118 * and is callable from both places. It uses SWIG's 00119 * "director" feature to implement the magic. 00120 * It's slow. Don't use it in a performance critical path. 00121 * 00122 * Override eval to define the behavior. 00123 * Use calleval to invoke eval (this kludge is required to allow a 00124 * python specific "shim" to be inserted. 00125 */ 00126 class GR_CORE_API gr_feval 00127 { 00128 protected: 00129 /*! 00130 * \brief override this to define the function 00131 */ 00132 virtual void eval(); 00133 00134 public: 00135 gr_feval() {} 00136 virtual ~gr_feval(); 00137 00138 virtual void calleval(); // invoke "eval" 00139 }; 00140 00141 /*! 00142 * \brief base class for evaluating a function: pmt -> void 00143 * \ingroup misc 00144 * 00145 * This class is designed to be subclassed in Python or C++ 00146 * and is callable from both places. It uses SWIG's 00147 * "director" feature to implement the magic. 00148 * It's slow. Don't use it in a performance critical path. 00149 * 00150 * Override eval to define the behavior. 00151 * Use calleval to invoke eval (this kludge is required to allow a 00152 * python specific "shim" to be inserted. 00153 */ 00154 class GR_CORE_API gr_feval_p 00155 { 00156 protected: 00157 /*! 00158 * \brief override this to define the function 00159 */ 00160 virtual void eval(pmt::pmt_t x); 00161 00162 public: 00163 gr_feval_p() {} 00164 virtual ~gr_feval_p(); 00165 00166 virtual void calleval(pmt::pmt_t x); // invoke "eval" 00167 }; 00168 00169 /*! 00170 * \brief trivial examples / test cases showing C++ calling Python code 00171 */ 00172 GR_CORE_API double gr_feval_dd_example(gr_feval_dd *f, double x); 00173 GR_CORE_API gr_complex gr_feval_cc_example(gr_feval_cc *f, gr_complex x); 00174 GR_CORE_API long gr_feval_ll_example(gr_feval_ll *f, long x); 00175 GR_CORE_API void gr_feval_example(gr_feval *f); 00176 00177 #endif /* INCLUDED_GR_FEVAL_H */