21template <
class myType>
 
   41template <
class myType>
 
   46                      std::string functionbase,
 
   54          d_functionbase(functionbase),
 
 
   72        myType rVal = d_deflt;
 
   73        if (d_callback == NULL) {
 
   75                << 
"WARNING: pycallback_object get() called without py callback set!" 
   80            PyGILState_STATE state = PyGILState_Ensure();
 
   86            func = (PyObject*)d_callback; 
 
   88            result = PyEval_CallObject(func, NULL); 
 
   92                rVal = pyCast(result);
 
   97            PyGILState_Release(state);
 
 
  109                d_name + std::to_string(d_id),
 
  110                d_functionbase.c_str(),
 
 
  124    PyObject* d_callback;
 
  125    std::string d_functionbase, d_units, d_desc;
 
  126    myType d_min, d_max, d_deflt;
 
  134    myType pyCast(PyObject* obj)
 
  136        std::cerr << 
"TYPE NOT IMPLEMENTED!" << std::endl;
 
  143    std::vector<rpcbasic_sptr> d_rpc_vars; 
 
 
  152std::string pycallback_object<std::string>::pyCast(PyObject* obj)
 
  154#if PY_MAJOR_VERSION >= 3 
  155    return std::string(PyUnicode_AsUTF8(obj));
 
  157    return std::string(PyString_AsString(obj));
 
  162double pycallback_object<double>::pyCast(PyObject* obj)
 
  164    return PyFloat_AsDouble(obj);
 
  168float pycallback_object<float>::pyCast(PyObject* obj)
 
  170    return (
float)PyFloat_AsDouble(obj);
 
  174int pycallback_object<int>::pyCast(PyObject* obj)
 
  176    return PyInt_AsLong(obj);
 
  182    int size = PyObject_Size(obj);
 
  183    std::vector<float> rval(size);
 
  184    for (
int i = 0; i < size; i++) {
 
  185        rval[i] = (float)PyFloat_AsDouble(PyList_GetItem(obj, i));
 
  193    int size = PyObject_Size(obj);
 
  194    std::vector<gr_complex> rval(size);
 
  195    for (
int i = 0; i < size; i++) {
 
  196        rval[i] = 
gr_complex((
float)PyComplex_RealAsDouble(PyList_GetItem(obj, i)),
 
  197                             (
float)PyComplex_ImagAsDouble(PyList_GetItem(obj, i)));
 
Definition pycallback_object.h:23
static pmt::pmt_t make(myType _val)
Definition pycallback_object.h:25
Definition pycallback_object.h:43
pycallback_object(std::string name, std::string functionbase, std::string units, std::string desc, myType min, myType max, myType deflt, DisplayType dtype)
Definition pycallback_object.h:45
void set_callback(PyObject *cb)
Definition pycallback_object.h:102
void add_rpc_variable(rpcbasic_sptr s)
Definition pycallback_object.h:68
void setup_rpc()
Definition pycallback_object.h:104
myType get()
Definition pycallback_object.h:70
Registers a 'get' function to get a parameter over ControlPort.
Definition rpcregisterhelpers.h:1107
std::complex< float > gr_complex
Definition gr_complex.h:15
PMT_API pmt_t init_f32vector(size_t k, const float *data)
PMT_API pmt_t init_c32vector(size_t k, const std::complex< float > *data)
static pmt_t mp(const std::string &s)
Make pmt symbol.
Definition pmt_sugar.h:24
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition pmt.h:83
int pycallback_object_count
Definition pycallback_object.h:18
pyport_t
Definition pycallback_object.h:16
@ PYPORT_FLOAT
Definition pycallback_object.h:16
@ PYPORT_STRING
Definition pycallback_object.h:16
@ RPC_PRIVLVL_MIN
Definition rpccallbackregister_base.h:34
uint32_t DisplayType
Definition rpccallbackregister_base.h:17