4 #ifndef DGPY_SIGNAL_WRAPPER
5 #define DGPY_SIGNAL_WRAPPER
7 #include <dynamic-graph/linear-algebra.h>
8 #include <dynamic-graph/signal.h>
9 #include <dynamic-graph/entity.h>
14 namespace signalWrapper {
15 void convert(PyObject* o,
int& v);
16 void convert(PyObject* o,
bool& v);
17 void convert(PyObject* o,
float& v);
18 void convert(PyObject* o,
double& v);
20 void convert(PyObject* o, Vector& v);
26 DYNAMIC_GRAPH_ENTITY_DECL();
33 void rmSignal(
const std::string& name);
36 template <
class T,
class Time>
44 typedef boost::function2<T&, T&, Time> function_t;
46 function_t f = boost::bind(&SignalWrapper::call,
this, _1, _2);
53 T& call(T& value, Time t) {
54 PyGILState_STATE gstate;
55 gstate = PyGILState_Ensure();
56 if (PyGILState_GetThisThreadState() == NULL) {
57 dgDEBUG(10) <<
"python thread not initialized" << std::endl;
60 PyObject* obj = PyObject_CallFunction(callable, format, t);
62 dgERROR <<
"Could not call callable" << std::endl;
67 PyGILState_Release(gstate);