|
1 | 1 | #include "dynamic-graph/python/module.hh"
|
| 2 | +#include "dynamic-graph/python/signal.hh" |
2 | 3 |
|
3 | 4 | #include <sot/core/device.hh>
|
| 5 | +#include <sot/core/flags.hh> |
4 | 6 |
|
5 | 7 | namespace dg = dynamicgraph;
|
6 | 8 | namespace dgs = dynamicgraph::sot;
|
@@ -44,4 +46,35 @@ BOOST_PYTHON_MODULE(wrap)
|
44 | 46 | .def_readonly("before",
|
45 | 47 | bp::make_function(&dgs::Device::periodicCallBefore, reference_existing_object()))
|
46 | 48 | ;
|
| 49 | + |
| 50 | + using dgs::Flags; |
| 51 | + bp::class_<Flags>("Flags", bp::init<const bool&>()) |
| 52 | + .def(bp::init<const char&>()) |
| 53 | + .def(bp::init<const int &>()) |
| 54 | + .def("add", static_cast<void(Flags::*)(const char&)>(&Flags::add)) |
| 55 | + .def("add", static_cast<void(Flags::*)(const int &)>(&Flags::add)) |
| 56 | + .def("set", &Flags::set) |
| 57 | + .def("unset", &Flags::unset) |
| 58 | + |
| 59 | + .def(bp::self & bool()) |
| 60 | + .def(bp::self | bool()) |
| 61 | + .def(bp::self &= bool()) |
| 62 | + .def(bp::self |= bool()) |
| 63 | + |
| 64 | + .def("__call__", &Flags::operator()) |
| 65 | + .def("__bool__", &Flags::operator bool) |
| 66 | + .def("reversed", &Flags::operator!) |
| 67 | + |
| 68 | + .def("set", +[](Flags& f, const std::string& s) { |
| 69 | + std::istringstream is (s); |
| 70 | + is >> f; |
| 71 | + }) |
| 72 | + .def("__str__", +[](const Flags& f) { |
| 73 | + std::ostringstream os; |
| 74 | + os << f; |
| 75 | + return os.str(); |
| 76 | + }) |
| 77 | + ; |
| 78 | + |
| 79 | + dg::python::exposeSignalsOfType<Flags, int>("Flags"); |
47 | 80 | }
|
0 commit comments