Directory: | ./ |
---|---|
File: | include/pinocchio/bindings/python/utils/printable.hpp |
Date: | 2024-08-27 18:20:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 3 | 3 | 100.0% |
Branches: | 2 | 4 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2016 CNRS | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_python_utils_printable_hpp__ | ||
6 | #define __pinocchio_python_utils_printable_hpp__ | ||
7 | |||
8 | #include <boost/python.hpp> | ||
9 | |||
10 | namespace pinocchio | ||
11 | { | ||
12 | namespace python | ||
13 | { | ||
14 | |||
15 | namespace bp = boost::python; | ||
16 | |||
17 | /// | ||
18 | /// \brief Set the Python method __str__ and __repr__ to use the overloading operator<<. | ||
19 | /// | ||
20 | template<class C> | ||
21 | struct PrintableVisitor : public bp::def_visitor<PrintableVisitor<C>> | ||
22 | { | ||
23 | template<class PyClass> | ||
24 | 2400 | void visit(PyClass & cl) const | |
25 | { | ||
26 |
2/4✓ Branch 2 taken 1260 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1260 times.
✗ Branch 7 not taken.
|
2400 | cl.def(bp::self_ns::str(bp::self_ns::self)).def(bp::self_ns::repr(bp::self_ns::self)); |
27 | 2400 | } | |
28 | }; | ||
29 | } // namespace python | ||
30 | } // namespace pinocchio | ||
31 | |||
32 | #endif // ifndef __pinocchio_python_utils_printable_hpp__ | ||
33 |