serializable.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017-2024 CNRS INRIA
3 // This file was borrowed from the Pinocchio library:
4 // https://github.com/stack-of-tasks/pinocchio
5 //
6 
7 #ifndef COAL_PYTHON_SERIALIZABLE_H
8 #define COAL_PYTHON_SERIALIZABLE_H
9 
10 #include <boost/python.hpp>
11 
14 
15 namespace coal {
16 namespace python {
17 
19 
20 namespace bp = boost::python;
21 
22 template <typename Derived>
24  : public bp::def_visitor<SerializableVisitor<Derived>> {
25  template <class PyClass>
26  void visit(PyClass& cl) const {
27  cl.def("saveToText", &Serializer::saveToText<Derived>, bp::arg("filename"),
28  "Saves *this inside a text file.")
29  .def("loadFromText", &Serializer::loadFromText<Derived>,
30  bp::arg("filename"), "Loads *this from a text file.")
31 
32  .def("saveToString", &Serializer::saveToString<Derived>,
33  bp::arg("self"), "Parses the current object to a string.")
34  .def("loadFromString", &Serializer::loadFromString<Derived>,
35  bp::args("self", "string"),
36  "Parses from the input string the content of the current object.")
37 
38  .def("saveToXML", &Serializer::saveToXML<Derived>,
39  bp::args("filename", "tag_name"), "Saves *this inside a XML file.")
40  .def("loadFromXML", &Serializer::loadFromXML<Derived>,
41  bp::args("self", "filename", "tag_name"),
42  "Loads *this from a XML file.")
43 
44  .def("saveToBinary", &Serializer::saveToBinary<Derived>,
45  bp::args("self", "filename"), "Saves *this inside a binary file.")
46  .def("loadFromBinary", &Serializer::loadFromBinary<Derived>,
47  bp::args("self", "filename"), "Loads *this from a binary file.")
48 
49  .def("saveToBuffer", &Serializer::saveToBuffer<Derived>,
50  bp::args("self", "buffer"), "Saves *this inside a binary buffer.")
51  .def("loadFromBuffer", &Serializer::loadFromBuffer<Derived>,
52  bp::args("self", "buffer"), "Loads *this from a binary buffer.");
53  }
54 };
55 } // namespace python
56 } // namespace coal
57 
58 #endif // ifndef COAL_PYTHON_SERIALIZABLE_H
boost::python
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::python::Serializer
::coal::serialization::Serializer Serializer
Definition: serializable.hh:18
coal::python::SerializableVisitor
Definition: serializable.hh:23
doxygen_xml_parser.args
args
Definition: doxygen_xml_parser.py:887
python
coal::serialization::Serializer
Definition: coal/serialization/serializer.h:13
archive.h
serializer.h
coal::python::SerializableVisitor::visit
void visit(PyClass &cl) const
Definition: serializable.hh:26
geometric_shapes.cl
cl
Definition: scripts/geometric_shapes.py:10


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:59