GNU Radio Manual and C++ API Reference  3.7.13.4
The Free & Open Software Radio Ecosystem
py_feval.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006,2013 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 
23 #ifndef INCLUDED_GR_PY_FEVAL_H
24 #define INCLUDED_GR_PY_FEVAL_H
25 
26 #include <Python.h>
27 #include <pmt/pmt.h>
28 #include <gnuradio/feval.h>
29 
31  PyGILState_STATE d_gstate;
32 public:
33  ensure_py_gil_state() { d_gstate = PyGILState_Ensure(); }
34  ~ensure_py_gil_state() { PyGILState_Release(d_gstate); }
35 };
36 
37 namespace gr {
38 
40  {
41  public:
42  double calleval(double x)
43  {
44  ensure_py_gil_state _lock;
45  return eval(x);
46  }
47  virtual ~py_feval_dd() {};
48  };
49 
51  {
52  public:
54  {
55  ensure_py_gil_state _lock;
56  return eval(x);
57  }
58  virtual ~py_feval_cc() {};
59  };
60 
62  {
63  public:
64  long calleval(long x)
65  {
66  ensure_py_gil_state _lock;
67  return eval(x);
68  }
69  virtual ~py_feval_ll() {};
70  };
71 
72  class GR_RUNTIME_API py_feval : public feval
73  {
74  public:
75  void calleval()
76  {
77  ensure_py_gil_state _lock;
78  eval();
79  }
80  virtual ~py_feval() {};
81  };
82 
84  {
85  public:
87  {
88  ensure_py_gil_state _lock;
89  eval(x);
90  }
91  virtual ~py_feval_p() {};
92  };
93 
94 } /* namespace gr */
95 
96 #endif /* INCLUDED_GR_PY_FEVAL_H */
gr_complex calleval(gr_complex x)
Definition: py_feval.h:53
long calleval(long x)
Definition: py_feval.h:64
double calleval(double x)
Definition: py_feval.h:42
~ensure_py_gil_state()
Definition: py_feval.h:34
Definition: py_feval.h:30
void calleval()
Definition: py_feval.h:75
Definition: py_feval.h:83
virtual ~py_feval_dd()
Definition: py_feval.h:47
base class for evaluating a function: long -> longThis class is designed to be subclassed in Python o...
Definition: feval.h:104
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
std::complex< float > gr_complex
Definition: gr_complex.h:27
Include this header to use the message passing features.
Definition: logger.h:695
virtual ~py_feval_cc()
Definition: py_feval.h:58
virtual ~py_feval()
Definition: py_feval.h:80
base class for evaluating a function: void -> voidThis class is designed to be subclassed in Python o...
Definition: feval.h:133
void calleval(pmt::pmt_t x)
Definition: py_feval.h:86
base class for evaluating a function: complex -> complexThis class is designed to be subclassed in Py...
Definition: feval.h:75
virtual ~py_feval_ll()
Definition: py_feval.h:69
Definition: py_feval.h:61
Definition: py_feval.h:72
ensure_py_gil_state()
Definition: py_feval.h:33
base class for evaluating a function: double -> doubleThis class is designed to be subclassed in Pyth...
Definition: feval.h:46
base class for evaluating a function: pmt -> voidThis class is designed to be subclassed in Python or...
Definition: feval.h:162
Definition: py_feval.h:39
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
Definition: pmt.h:56
virtual ~py_feval_p()
Definition: py_feval.h:91
Definition: py_feval.h:50