bindings/python/serialization/serializable.hpp
Go to the documentation of this file.
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 
10 
11 namespace 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
74 #endif
75  }
76  };
77  } // namespace python
78 } // namespace pinocchio
79 
80 #endif // ifndef __pinocchio_python_serialization_serializable_hpp__
pinocchio::serialization::loadFromXML
void loadFromXML(T &object, const std::string &filename, const std::string &tag_name)
Loads an object from a XML file.
Definition: archive.hpp:174
boost::python
pinocchio::serialization::loadFromString
void loadFromString(T &object, const std::string &str)
Loads an object from a std::string.
Definition: archive.hpp:141
serializable.hpp
pinocchio::serialization::StaticBuffer
Static buffer with pre-allocated memory.
Definition: static-buffer.hpp:16
serialization.hpp
pinocchio::serialization::saveToString
std::string saveToString(const T &object)
Saves an object inside a std::string.
Definition: archive.hpp:157
pinocchio::serialization::saveToText
void saveToText(const T &object, const std::string &filename)
Saves an object inside a TXT file.
Definition: archive.hpp:87
python
pinocchio::serialization::saveToXML
void saveToXML(const T &object, const std::string &filename, const std::string &tag_name)
Saves an object inside a XML file.
Definition: archive.hpp:204
pinocchio::python::SerializableVisitor
Definition: bindings/python/serialization/serializable.hpp:19
cl
cl
pinocchio::serialization::loadFromText
void loadFromText(T &object, const std::string &filename)
Loads an object from a TXT file.
Definition: archive.hpp:61
pinocchio::python::SerializableVisitor::visit
void visit(PyClass &cl) const
Definition: bindings/python/serialization/serializable.hpp:23
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
PINOCCHIO_UNUSED_VARIABLE
#define PINOCCHIO_UNUSED_VARIABLE(var)
Helper to declare that a parameter is unused.
Definition: include/pinocchio/macros.hpp:72


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:32