GCC Code Coverage Report


Directory: ./
File: include/pinocchio/bindings/python/serialization/serializable.hpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 16 16 100.0%
Branches: 23 46 50.0%

Line Branch Exec Source
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
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 160 void visit(PyClass & cl) const
24 {
25 #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
26 160 cl.def(
27 "saveToText", &Derived::saveToText, bp::args("self", "filename"),
28 "Saves *this inside a text file.")
29
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
30 "loadFromText", &Derived::loadFromText, bp::args("self", "filename"),
31 "Loads *this from a text file.")
32
33
1/2
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
160 .def(
34
1/2
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
320 "saveToString", &Derived::saveToString, bp::arg("self"),
35 "Parses the current object to a string.")
36
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
37 "loadFromString", &Derived::loadFromString, bp::args("self", "string"),
38 "Parses from the input string the content of the current object.")
39
40
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
41 "saveToXML", &Derived::saveToXML, bp::args("filename", "tag_name"),
42 "Saves *this inside a XML file.")
43
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
44 "loadFromXML", &Derived::loadFromXML, bp::args("self", "filename", "tag_name"),
45 "Loads *this from a XML file.")
46
47
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
48 "saveToBinary", (void(Derived::*)(const std::string &) const) & Derived::saveToBinary,
49 bp::args("self", "filename"), "Saves *this inside a binary file.")
50
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
51 "loadFromBinary", (void(Derived::*)(const std::string &)) & Derived::loadFromBinary,
52 bp::args("self", "filename"), "Loads *this from a binary file.")
53
54
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
55 "saveToBinary",
56 (void(Derived::*)(boost::asio::streambuf &) const) & Derived::saveToBinary,
57 bp::args("self", "buffer"), "Saves *this inside a binary buffer.")
58
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
59 "loadFromBinary",
60 (void(Derived::*)(boost::asio::streambuf &)) & Derived::loadFromBinary,
61 bp::args("self", "buffer"), "Loads *this from a binary buffer.")
62
63
2/4
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
320 .def(
64 "saveToBinary",
65 (void(Derived::*)(serialization::StaticBuffer &) const) & Derived::saveToBinary,
66 bp::args("self", "buffer"), "Saves *this inside a static binary buffer.")
67
3/6
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 100 times.
✗ Branch 8 not taken.
160 .def(
68 "loadFromBinary",
69 (void(Derived::*)(serialization::StaticBuffer &)) & Derived::loadFromBinary,
70 bp::args("self", "buffer"), "Loads *this from a static binary buffer.");
71 160 serialize<Derived>();
72 #else
73 PINOCCHIO_UNUSED_VARIABLE(cl);
74 #endif
75 160 }
76 };
77 } // namespace python
78 } // namespace pinocchio
79
80 #endif // ifndef __pinocchio_python_serialization_serializable_hpp__
81