GCC Code Coverage Report


Directory: ./
File: include/pinocchio/bindings/python/utils/copyable.hpp
Date: 2024-08-27 18:20:05
Exec Total Coverage
Lines: 7 9 77.8%
Branches: 3 6 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2016-2023 CNRS INRIA
3 //
4
5 #ifndef __pinocchio_python_utils_copyable_hpp__
6 #define __pinocchio_python_utils_copyable_hpp__
7
8 #include <eigenpy/eigenpy.hpp>
9
10 namespace pinocchio
11 {
12 namespace python
13 {
14
15 namespace bp = boost::python;
16
17 ///
18 /// \brief Add the Python method copy to allow a copy of this by calling the copy constructor.
19 ///
20 template<class C>
21 struct CopyableVisitor : public bp::def_visitor<CopyableVisitor<C>>
22 {
23 template<class PyClass>
24 420 void visit(PyClass & cl) const
25 {
26
1/2
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
420 cl.def("copy", &copy, bp::arg("self"), "Returns a copy of *this.");
27
1/2
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
420 cl.def("__copy__", &copy, bp::arg("self"), "Returns a copy of *this.");
28
1/2
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
420 cl.def(
29 "__deepcopy__", &deepcopy, bp::args("self", "memo"), "Returns a deep copy of *this.");
30 420 }
31
32 private:
33 7 static C copy(const C & self)
34 {
35 7 return C(self);
36 }
37 static C deepcopy(const C & self, bp::dict)
38 {
39 return C(self);
40 }
41 };
42 } // namespace python
43 } // namespace pinocchio
44
45 #endif // ifndef __pinocchio_python_utils_copyable_hpp__
46