4 #ifndef DGPY_SIGNAL_WRAPPER 5 #define DGPY_SIGNAL_WRAPPER 7 #include <boost/python.hpp> 8 #include <boost/bind.hpp> 10 #include <dynamic-graph/linear-algebra.h> 11 #include <dynamic-graph/signal.h> 12 #include <dynamic-graph/entity.h> 19 DYNAMIC_GRAPH_ENTITY_DECL();
26 void rmSignal(
const std::string& name);
29 template <
class T,
class Time>
35 static bool checkCallable(pyobject c, std::string& error);
37 SignalWrapper(std::string name, pyobject callable) : parent_t(name), callable(callable) {
38 typedef boost::function2<T&, T&, Time> function_t;
39 function_t f = boost::bind(&SignalWrapper::call,
this, _1, _2);
46 T& call(T& value, Time t) {
47 PyGILState_STATE gstate;
48 gstate = PyGILState_Ensure();
49 if (PyGILState_GetThisThreadState() == NULL) {
50 dgDEBUG(10) <<
"python thread not initialized" << std::endl;
52 pyobject obj = callable(t);
53 value = boost::python::extract<T>(obj);
54 PyGILState_Release(gstate);
Definition: signal-wrapper.hh:18
Definition: signal-wrapper.hh:30
SignalWrapper(std::string name, pyobject callable)
Definition: signal-wrapper.hh:37
Signal< T, Time > parent_t
Definition: signal-wrapper.hh:32
void rmSignal(const std::string &name)
Definition: signal-wrapper.cc:15
boost::python::object pyobject
Definition: signal-wrapper.hh:33
virtual ~SignalWrapper()
Definition: signal-wrapper.hh:43
void signalRegistration(const SignalArray< int > &signals)
Definition: signal-wrapper.cc:11
Definition: convert-dg-to-py.hh:8