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