GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2006,2013 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 00023 #ifndef INCLUDED_GR_PY_FEVAL_H 00024 #define INCLUDED_GR_PY_FEVAL_H 00025 00026 #include <pmt/pmt.h> 00027 #include <gnuradio/feval.h> 00028 00029 class ensure_py_gil_state { 00030 PyGILState_STATE d_gstate; 00031 public: 00032 ensure_py_gil_state() { d_gstate = PyGILState_Ensure(); } 00033 ~ensure_py_gil_state() { PyGILState_Release(d_gstate); } 00034 }; 00035 00036 namespace gr { 00037 00038 class GR_RUNTIME_API py_feval_dd : public feval_dd 00039 { 00040 public: 00041 double calleval(double x) 00042 { 00043 ensure_py_gil_state _lock; 00044 return eval(x); 00045 } 00046 virtual ~py_feval_dd() {}; 00047 }; 00048 00049 class GR_RUNTIME_API py_feval_cc : public feval_cc 00050 { 00051 public: 00052 gr_complex calleval(gr_complex x) 00053 { 00054 ensure_py_gil_state _lock; 00055 return eval(x); 00056 } 00057 virtual ~py_feval_cc() {}; 00058 }; 00059 00060 class GR_RUNTIME_API py_feval_ll : public feval_ll 00061 { 00062 public: 00063 long calleval(long x) 00064 { 00065 ensure_py_gil_state _lock; 00066 return eval(x); 00067 } 00068 virtual ~py_feval_ll() {}; 00069 }; 00070 00071 class GR_RUNTIME_API py_feval : public feval 00072 { 00073 public: 00074 void calleval() 00075 { 00076 ensure_py_gil_state _lock; 00077 eval(); 00078 } 00079 virtual ~py_feval() {}; 00080 }; 00081 00082 class GR_RUNTIME_API py_feval_p : public feval_p 00083 { 00084 public: 00085 void calleval(pmt::pmt_t x) 00086 { 00087 ensure_py_gil_state _lock; 00088 eval(x); 00089 } 00090 virtual ~py_feval_p() {}; 00091 }; 00092 00093 } /* namespace gr */ 00094 00095 #endif /* INCLUDED_GR_PY_FEVAL_H */