Loading...
Searching...
No Matches
curve-map.hpp
Go to the documentation of this file.
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
19
20template <typename Curve>
21struct CurveMap : public std::map<std::string, Curve> {
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 bool operator==(const CurveMap_t& other) const {
28 if (this->size() != other.size()) return false;
29 for (typename Parent::const_iterator it = this->begin(); it != this->end();
30 ++it) {
31 if (other.count(it->first) < 1) return false;
32 if ((it->second != other.at(it->first)) &&
33 !(it->second->isApprox(other.at(it->first).get())))
34 return false;
35 }
36 return true;
37 }
38
39 bool operator!=(const CurveMap_t& other) const { return !(*this == other); }
40
42 template <class Archive>
43 void serialize(Archive& ar, const unsigned int /*version*/) {
44 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Parent);
45 }
46};
47
48#endif // CURVEMAP_HPP
Definition curve-map.hpp:21
std::map< std::string, Curve > Parent
Definition curve-map.hpp:23
void serialize(Archive &ar, const unsigned int)
Definition curve-map.hpp:43
bool operator==(const CurveMap_t &other) const
Definition curve-map.hpp:27
friend class boost::serialization::access
Definition curve-map.hpp:41
bool operator!=(const CurveMap_t &other) const
Definition curve-map.hpp:39
CurveMap< Curve > CurveMap_t
Definition curve-map.hpp:22