Directory: | ./ |
---|---|
File: | include/multicontact-api/geometry/curve-map.hpp |
Date: | 2025-03-10 16:17:01 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 12 | 12 | 100.0% |
Branches: | 16 | 22 | 72.7% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2019-2020, CNRS | ||
2 | // Authors: Pierre Fernbach <pfernbac@laas.fr> | ||
3 | |||
4 | #ifndef __multicontact_api_geometry_curve_map_hpp__ | ||
5 | #define __multicontact_api_geometry_curve_map_hpp__ | ||
6 | |||
7 | #include <ndcurves/curve_abc.h> | ||
8 | |||
9 | #include <boost/serialization/access.hpp> | ||
10 | #include <boost/serialization/base_object.hpp> | ||
11 | #include <boost/serialization/map.hpp> | ||
12 | #include <boost/serialization/shared_ptr.hpp> | ||
13 | #include <boost/serialization/string.hpp> | ||
14 | #include <map> | ||
15 | #include <ndcurves/serialization/registeration.hpp> | ||
16 | #include <string> | ||
17 | |||
18 | #include "multicontact-api/serialization/archive.hpp" | ||
19 | |||
20 | template <typename Curve> | ||
21 | struct CurveMap : public std::map<std::string, Curve> { | ||
22 | typedef CurveMap<Curve> CurveMap_t; | ||
23 | typedef std::map<std::string, Curve> Parent; | ||
24 | |||
25 | // define operator == for map of shared ptr: start by checking if the ptr are | ||
26 | // same, otherwise check if the values are the sames | ||
27 | 1622 | bool operator==(const CurveMap_t& other) const { | |
28 |
2/2✓ Branch 2 taken 7 times.
✓ Branch 3 taken 804 times.
|
1622 | if (this->size() != other.size()) return false; |
29 |
2/2✓ Branch 3 taken 1179 times.
✓ Branch 4 taken 798 times.
|
3954 | for (typename Parent::const_iterator it = this->begin(); it != this->end(); |
30 | 2346 | ++it) { | |
31 |
2/4✓ Branch 2 taken 1179 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1179 times.
|
2370 | if (other.count(it->first) < 1) return false; |
32 |
5/6✓ Branch 2 taken 1179 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 474 times.
✓ Branch 7 taken 705 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 1173 times.
|
3306 | if ((it->second != other.at(it->first)) && |
33 |
4/6✓ Branch 5 taken 474 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 474 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 468 times.
|
948 | !(it->second->isApprox(other.at(it->first).get()))) |
34 | 12 | return false; | |
35 | } | ||
36 | 1596 | return true; | |
37 | } | ||
38 | |||
39 | bool operator!=(const CurveMap_t& other) const { return !(*this == other); } | ||
40 | |||
41 | friend class boost::serialization::access; | ||
42 | template <class Archive> | ||
43 | 972 | void serialize(Archive& ar, const unsigned int /*version*/) { | |
44 |
1/2✓ Branch 3 taken 486 times.
✗ Branch 4 not taken.
|
972 | ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Parent); |
45 | 972 | } | |
46 | }; | ||
47 | |||
48 | #endif // CURVEMAP_HPP | ||
49 |