hpp-core  4.12.0
Implement basic classes for canonical path planning for kinematic chains.
roadmap.hh
Go to the documentation of this file.
1 // Copyright (c) 2020 CNRS
2 // Authors: Joseph Mirabel
3 //
4 // This file is part of hpp-core
5 // hpp-core is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-core is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-core If not, see
16 // <http://www.gnu.org/licenses/>.
17 
18 #ifndef HPP_CORE_PARSER_ROADMAP_HH
19 # define HPP_CORE_PARSER_ROADMAP_HH
20 
21 # include <fstream>
22 
23 # include <hpp/core/roadmap.hh>
24 # include <hpp/pinocchio/serialization.hh>
25 
26 namespace hpp {
27 namespace core {
28 namespace parser {
29 namespace internal {
30 
31 template<typename Parent, typename Child>
32 struct InsertChildClass : std::pair<std::string, Child*>
33 {
34  using std::pair<std::string, Child>::pair;
35 };
36 
37 template<class Archive, class A>
38 inline void insert(Archive& ar, const std::pair<std::string, A*>& a)
39 {
40  ar.insert(a.first, a.second);
41 }
42 
43 template<class Archive, class Parent, class Child>
44 inline void insert(Archive& ar, const InsertChildClass<Parent, Child>& a)
45 {
46  ar.template insertChildClass<Parent, Child>(a.first, a.second);
47 }
48 
49 template<class Archive> inline void inserts(Archive&) {}
50 template<class Archive, class A, class... B>
51 inline void inserts(Archive& ar, A& a, B&... b)
52 {
53  insert(ar, a);
54  inserts(ar, b...);
55 }
56 } // namespace internal
57 
66 template<class A>
67 std::pair<std::string, A*> make_nvp (const std::string& n, A* a)
68 { return std::pair<std::string, A*> (n, a); }
69 template<class Parent, class Child>
72 
73 template<class Archive, class... Args>
74 void serializeRoadmap (RoadmapPtr_t& roadmap, const std::string& filename, Args... args)
75 {
76  typename std::conditional<Archive::is_saving::value,
77  std::ofstream, std::ifstream>::type
78  fs (filename);
79  Archive ar (fs);
80  internal::inserts(ar, args...);
81  ar.initialize();
82  ar & hpp::serialization::make_nvp("roadmap", roadmap);
83 }
85 } // namespace parser
86 } // namespace core
87 } // namespace hpp
88 #endif // HPP_CORE_PARSER_ROADMAP_HH
void insert(Archive &ar, const std::pair< std::string, A *> &a)
Definition: roadmap.hh:38
Definition: bi-rrt-planner.hh:24
void serializeRoadmap(RoadmapPtr_t &roadmap, const std::string &filename, Args... args)
Definition: roadmap.hh:74
internal::InsertChildClass< Parent, Child > make_nvp_with_parent(const std::string &n, Child *a)
Definition: roadmap.hh:70
void inserts(Archive &)
Definition: roadmap.hh:49
shared_ptr< Roadmap > RoadmapPtr_t
Definition: fwd.hh:182
std::pair< std::string, A * > make_nvp(const std::string &n, A *a)
Definition: roadmap.hh:67