pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
serializable.hpp
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 "pinocchio/serialization/serializable.hpp"
9#include "pinocchio/bindings/python/serialization/serialization.hpp"
10
11namespace pinocchio
12{
13 namespace python
14 {
15
16 namespace bp = boost::python;
17
18 template<typename Derived>
19 struct SerializableVisitor : public bp::def_visitor<SerializableVisitor<Derived>>
20 {
21
22 template<class PyClass>
23 void visit(PyClass & cl) const
24 {
25#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
26 cl.def(
27 "saveToText", &Derived::saveToText, bp::args("self", "filename"),
28 "Saves *this inside a text file.")
29 .def(
30 "loadFromText", &Derived::loadFromText, bp::args("self", "filename"),
31 "Loads *this from a text file.")
32
33 .def(
34 "saveToString", &Derived::saveToString, bp::arg("self"),
35 "Parses the current object to a string.")
36 .def(
37 "loadFromString", &Derived::loadFromString, bp::args("self", "string"),
38 "Parses from the input string the content of the current object.")
39
40 .def(
41 "saveToXML", &Derived::saveToXML, bp::args("filename", "tag_name"),
42 "Saves *this inside a XML file.")
43 .def(
44 "loadFromXML", &Derived::loadFromXML, bp::args("self", "filename", "tag_name"),
45 "Loads *this from a XML file.")
46
47 .def(
48 "saveToBinary", (void(Derived::*)(const std::string &) const) & Derived::saveToBinary,
49 bp::args("self", "filename"), "Saves *this inside a binary file.")
50 .def(
51 "loadFromBinary", (void(Derived::*)(const std::string &)) & Derived::loadFromBinary,
52 bp::args("self", "filename"), "Loads *this from a binary file.")
53
54 .def(
55 "saveToBinary",
56 (void(Derived::*)(boost::asio::streambuf &) const) & Derived::saveToBinary,
57 bp::args("self", "buffer"), "Saves *this inside a binary buffer.")
58 .def(
59 "loadFromBinary",
60 (void(Derived::*)(boost::asio::streambuf &)) & Derived::loadFromBinary,
61 bp::args("self", "buffer"), "Loads *this from a binary buffer.")
62
63 .def(
64 "saveToBinary",
65 (void(Derived::*)(serialization::StaticBuffer &) const) & Derived::saveToBinary,
66 bp::args("self", "buffer"), "Saves *this inside a static binary buffer.")
67 .def(
68 "loadFromBinary",
69 (void(Derived::*)(serialization::StaticBuffer &)) & Derived::loadFromBinary,
70 bp::args("self", "buffer"), "Loads *this from a static binary buffer.");
71 serialize<Derived>();
72#else
73 PINOCCHIO_UNUSED_VARIABLE(cl);
74#endif
75 }
76 };
77 } // namespace python
78} // namespace pinocchio
79
80#endif // ifndef __pinocchio_python_serialization_serializable_hpp__
Main pinocchio namespace.
Definition treeview.dox:11