signal.hh
Go to the documentation of this file.
1 // Copyright 2020, Joseph Mirabel, LAAS-CNRS.
2 
6 #include <dynamic-graph/signal.h>
7 
8 #include <boost/python.hpp>
9 #include <sstream>
10 
12 
13 namespace dynamicgraph {
14 namespace python {
15 
16 template <typename T, typename Time>
17 auto exposeSignal(const std::string& name) {
18  namespace bp = boost::python;
19 
20  typedef Signal<T, Time> S_t;
21  bp::class_<S_t, bp::bases<SignalBase<Time> >, boost::noncopyable> obj(
22  name.c_str(), bp::init<std::string>());
23  obj.add_property(
24  "value",
25  bp::make_function(&S_t::accessCopy,
26  bp::return_value_policy<bp::copy_const_reference>()),
27  &S_t::setConstant, // TODO check the setter
28  "the signal value.\n"
29  "warning: for Eigen objects, sig.value[0] = 1. may not work).");
30  return obj;
31 }
32 
33 template <typename T, typename Time>
34 auto exposeSignalWrapper(const std::string& name) {
35  namespace bp = boost::python;
36 
37  typedef SignalWrapper<T, Time> S_t;
38  bp::class_<S_t, bp::bases<Signal<T, Time> >, boost::noncopyable> obj(
39  name.c_str(), bp::no_init);
40  return obj;
41 }
42 
43 template <typename T, typename Time>
44 auto exposeSignalPtr(const std::string& name) {
45  namespace bp = boost::python;
46 
47  typedef SignalPtr<T, Time> S_t;
48  bp::class_<S_t, bp::bases<Signal<T, Time> >, boost::noncopyable> obj(
49  name.c_str(), bp::no_init);
50  return obj;
51 }
52 
53 template <typename T, typename Time>
54 auto exposeSignalTimeDependent(const std::string& name) {
55  namespace bp = boost::python;
56 
57  typedef SignalTimeDependent<T, Time> S_t;
58  bp::class_<S_t, bp::bases<Signal<T, Time> >, boost::noncopyable> obj(
59  name.c_str(), bp::no_init);
60  return obj;
61 }
62 
63 template <typename T, typename Time>
64 void exposeSignalsOfType(const std::string& name) {
65  exposeSignal<T, Time>("Signal" + name);
66  exposeSignalPtr<T, Time>("SignalPtr" + name);
67  exposeSignalWrapper<T, Time>("SignalWrapper" + name);
68  exposeSignalTimeDependent<T, Time>("SignalTimeDependent" + name);
69 }
70 
71 } // namespace python
72 } // namespace dynamicgraph
void exposeSignalsOfType(const std::string &name)
Definition: signal.hh:64
auto exposeSignal(const std::string &name)
Definition: signal.hh:17
auto exposeSignalTimeDependent(const std::string &name)
Definition: signal.hh:54
auto exposeSignalWrapper(const std::string &name)
Definition: signal.hh:34
auto exposeSignalPtr(const std::string &name)
Definition: signal.hh:44


dynamic-graph-python
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:55:50