printable.hpp
Go to the documentation of this file.
1 // Copyright (c) 2015-2018, CNRS
2 // Authors: Justin Carpentier <jcarpent@laas.fr>
3 
4 #ifndef __multicontact_api_python_utils_printable_hpp__
5 #define __multicontact_api_python_utils_printable_hpp__
6 
8 
9 namespace multicontact_api {
10 namespace python {
11 
12 namespace bp = boost::python;
13 
18 template <class C>
19 struct PrintableVisitor : public bp::def_visitor<PrintableVisitor<C> > {
20  template <class PyClass>
21  void visit(PyClass& cl) const {
22  cl.def(bp::self_ns::str(bp::self_ns::self))
23  .def(bp::self_ns::repr(bp::self_ns::self));
24  }
25 };
26 
27 } // namespace python
28 } // namespace multicontact_api
29 
30 #endif // ifndef __multicontact_api_python_utils_printable_hpp__
Definition: ellipsoid.hpp:12
Set the Python method str and repr to use the overloading operator<<.
Definition: printable.hpp:19
void visit(PyClass &cl) const
Definition: printable.hpp:21