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