Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2019-2020, University of Edinburgh |
5 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
6 |
|
|
// All rights reserved. |
7 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
8 |
|
|
|
9 |
|
|
#ifndef BINDINGS_PYTHON_CROCODDYL_UTILS_PRINTABLE_HPP_ |
10 |
|
|
#define BINDINGS_PYTHON_CROCODDYL_UTILS_PRINTABLE_HPP_ |
11 |
|
|
|
12 |
|
|
#include <boost/python.hpp> |
13 |
|
|
|
14 |
|
|
namespace crocoddyl { |
15 |
|
|
namespace python { |
16 |
|
|
namespace bp = boost::python; |
17 |
|
|
|
18 |
|
|
/// |
19 |
|
|
/// \brief Set the Python method __str__ and __repr__ to use the overloading |
20 |
|
|
/// operator<<. |
21 |
|
|
/// |
22 |
|
|
template <class C> |
23 |
|
|
struct PrintableVisitor : public bp::def_visitor<PrintableVisitor<C> > { |
24 |
|
|
template <class PyClass> |
25 |
|
✗ |
void visit(PyClass& cl) const { |
26 |
|
✗ |
cl.def(bp::self_ns::str(bp::self_ns::self)) |
27 |
|
✗ |
.def(bp::self_ns::repr(bp::self_ns::self)); |
28 |
|
|
} |
29 |
|
|
}; |
30 |
|
|
|
31 |
|
|
} // namespace python |
32 |
|
|
} // namespace crocoddyl |
33 |
|
|
|
34 |
|
|
#endif // BINDINGS_PYTHON_CROCODDYL_UTILS_PRINTABLE_HPP_ |
35 |
|
|
|