1 |
|
|
// |
2 |
|
|
// Copyright (c) 2017-2021 CNRS INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifndef __pinocchio_python_serialization_serializable_hpp__ |
6 |
|
|
#define __pinocchio_python_serialization_serializable_hpp__ |
7 |
|
|
|
8 |
|
|
#include <boost/python.hpp> |
9 |
|
|
|
10 |
|
|
#include "pinocchio/serialization/serializable.hpp" |
11 |
|
|
#include "pinocchio/bindings/python/serialization/serialization.hpp" |
12 |
|
|
|
13 |
|
|
namespace pinocchio |
14 |
|
|
{ |
15 |
|
|
namespace python |
16 |
|
|
{ |
17 |
|
|
|
18 |
|
|
namespace bp = boost::python; |
19 |
|
|
|
20 |
|
|
template<typename Derived> |
21 |
|
|
struct SerializableVisitor |
22 |
|
|
: public bp::def_visitor< SerializableVisitor<Derived> > |
23 |
|
|
{ |
24 |
|
|
|
25 |
|
|
template<class PyClass> |
26 |
|
57 |
void visit(PyClass& cl) const |
27 |
|
|
{ |
28 |
✓✗ |
57 |
cl |
29 |
|
|
.def("saveToText",&Derived::saveToText, |
30 |
|
|
bp::arg("filename"),"Saves *this inside a text file.") |
31 |
|
57 |
.def("loadFromText",&Derived::loadFromText, |
32 |
|
|
bp::arg("filename"),"Loads *this from a text file.") |
33 |
|
|
|
34 |
✓✗✓✗
|
114 |
.def("saveToString",&Derived::saveToString, |
35 |
|
|
bp::arg("self"), |
36 |
|
|
"Parses the current object to a string.") |
37 |
✓✗✓✗
|
114 |
.def("loadFromString",&Derived::loadFromString, |
38 |
|
|
bp::args("self","string"), |
39 |
|
|
"Parses from the input string the content of the current object.") |
40 |
|
|
|
41 |
✓✗✓✗
|
114 |
.def("saveToXML",&Derived::saveToXML, |
42 |
|
|
bp::args("filename","tag_name"),"Saves *this inside a XML file.") |
43 |
✓✗✓✗
|
114 |
.def("loadFromXML",&Derived::loadFromXML, |
44 |
|
|
bp::args("self","filename","tag_name"),"Loads *this from a XML file.") |
45 |
|
|
|
46 |
✓✗✓✗
|
114 |
.def("saveToBinary",(void (Derived::*)(const std::string &) const)&Derived::saveToBinary, |
47 |
|
|
bp::args("self","filename"),"Saves *this inside a binary file.") |
48 |
✓✗✓✗
|
114 |
.def("loadFromBinary",(void (Derived::*)(const std::string &))&Derived::loadFromBinary, |
49 |
|
|
bp::args("self","filename"),"Loads *this from a binary file.") |
50 |
|
|
|
51 |
✓✗✓✗
|
114 |
.def("saveToBinary",(void (Derived::*)(boost::asio::streambuf &) const)&Derived::saveToBinary, |
52 |
|
|
bp::args("self","buffer"),"Saves *this inside a binary buffer.") |
53 |
✓✗✓✗
|
114 |
.def("loadFromBinary",(void (Derived::*)(boost::asio::streambuf &))&Derived::loadFromBinary, |
54 |
|
|
bp::args("self","buffer"),"Loads *this from a binary buffer.") |
55 |
|
|
|
56 |
✓✗✓✗
|
114 |
.def("saveToBinary",(void (Derived::*)(serialization::StaticBuffer &) const)&Derived::saveToBinary, |
57 |
|
|
bp::args("self","buffer"),"Saves *this inside a static binary buffer.") |
58 |
✓✗✓✗ ✓✗✓✗
|
114 |
.def("loadFromBinary",(void (Derived::*)(serialization::StaticBuffer &))&Derived::loadFromBinary, |
59 |
|
|
bp::args("self","buffer"),"Loads *this from a static binary buffer.") |
60 |
|
|
; |
61 |
|
|
|
62 |
|
57 |
serialize<Derived>(); |
63 |
|
57 |
} |
64 |
|
|
|
65 |
|
|
}; |
66 |
|
|
} |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
#endif // ifndef __pinocchio_python_serialization_serializable_hpp__ |