| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2020 CNRS |
| 3 |
|
|
// Authors: Joseph Mirabel |
| 4 |
|
|
// |
| 5 |
|
|
|
| 6 |
|
|
// Redistribution and use in source and binary forms, with or without |
| 7 |
|
|
// modification, are permitted provided that the following conditions are |
| 8 |
|
|
// met: |
| 9 |
|
|
// |
| 10 |
|
|
// 1. Redistributions of source code must retain the above copyright |
| 11 |
|
|
// notice, this list of conditions and the following disclaimer. |
| 12 |
|
|
// |
| 13 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright |
| 14 |
|
|
// notice, this list of conditions and the following disclaimer in the |
| 15 |
|
|
// documentation and/or other materials provided with the distribution. |
| 16 |
|
|
// |
| 17 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 |
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 |
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 |
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 |
|
|
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 |
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 |
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 28 |
|
|
// DAMAGE. |
| 29 |
|
|
|
| 30 |
|
|
#include <boost/serialization/version.hpp> |
| 31 |
|
|
#if BOOST_VERSION / 100 % 1000 == 74 |
| 32 |
|
|
#include <boost/serialization/library_version_type.hpp> |
| 33 |
|
|
#endif |
| 34 |
|
|
// ref https://github.com/boostorg/serialization/issues/219 |
| 35 |
|
|
|
| 36 |
|
|
#include <boost/serialization/list.hpp> |
| 37 |
|
|
#include <boost/serialization/serialization.hpp> |
| 38 |
|
|
#include <boost/serialization/set.hpp> |
| 39 |
|
|
#include <boost/serialization/weak_ptr.hpp> |
| 40 |
|
|
#include <hpp/manipulation/device.hh> |
| 41 |
|
|
#include <hpp/manipulation/leaf-connected-comp.hh> |
| 42 |
|
|
#include <hpp/manipulation/roadmap-node.hh> |
| 43 |
|
|
#include <hpp/manipulation/roadmap.hh> |
| 44 |
|
|
#include <hpp/manipulation/serialization.hh> |
| 45 |
|
|
#include <hpp/util/serialization.hh> |
| 46 |
|
|
#include <pinocchio/serialization/eigen.hpp> |
| 47 |
|
|
|
| 48 |
|
|
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::RoadmapNode) |
| 49 |
|
|
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::ConnectedComponent) |
| 50 |
|
|
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::WeighedLeafConnectedComp) |
| 51 |
|
|
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::Roadmap) |
| 52 |
|
|
|
| 53 |
|
|
namespace hpp { |
| 54 |
|
|
namespace manipulation { |
| 55 |
|
|
|
| 56 |
|
|
template <typename Archive> |
| 57 |
|
✗ |
inline void RoadmapNode::serialize(Archive& ar, const unsigned int version) { |
| 58 |
|
|
using namespace boost::serialization; |
| 59 |
|
|
(void)version; |
| 60 |
|
✗ |
ar& make_nvp("base", base_object<core::Node>(*this)); |
| 61 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(state_); |
| 62 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(leafCC_); |
| 63 |
|
|
} |
| 64 |
|
|
HPP_SERIALIZATION_IMPLEMENT(RoadmapNode); |
| 65 |
|
|
|
| 66 |
|
|
template <typename Archive> |
| 67 |
|
✗ |
inline void ConnectedComponent::serialize(Archive& ar, |
| 68 |
|
|
const unsigned int version) { |
| 69 |
|
|
using namespace boost::serialization; |
| 70 |
|
|
(void)version; |
| 71 |
|
✗ |
ar& make_nvp("base", base_object<core::ConnectedComponent>(*this)); |
| 72 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(roadmap_); |
| 73 |
|
|
if (!Archive::is_saving::value) { |
| 74 |
|
✗ |
RoadmapPtr_t roadmap = roadmap_.lock(); |
| 75 |
|
✗ |
for (const core::NodePtr_t& node : nodes()) { |
| 76 |
|
✗ |
const RoadmapNodePtr_t& n = static_cast<RoadmapNodePtr_t>(node); |
| 77 |
|
✗ |
graphStateMap_[roadmap->getState(n)].push_back(n); |
| 78 |
|
|
} |
| 79 |
|
|
} |
| 80 |
|
|
// ar & BOOST_SERIALIZATION_NVP(graphStateMap_); |
| 81 |
|
|
} |
| 82 |
|
|
HPP_SERIALIZATION_IMPLEMENT(ConnectedComponent); |
| 83 |
|
|
|
| 84 |
|
|
template <typename Archive> |
| 85 |
|
✗ |
inline void LeafConnectedComp::serialize(Archive& ar, |
| 86 |
|
|
const unsigned int version) { |
| 87 |
|
|
(void)version; |
| 88 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(state_); |
| 89 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(nodes_); |
| 90 |
|
|
|
| 91 |
|
|
// ar & BOOST_SERIALIZATION_NVP(explored_); |
| 92 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(roadmap_); |
| 93 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(to_); |
| 94 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(from_); |
| 95 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(weak_); |
| 96 |
|
|
} |
| 97 |
|
|
HPP_SERIALIZATION_IMPLEMENT(LeafConnectedComp); |
| 98 |
|
|
|
| 99 |
|
|
template <typename Archive> |
| 100 |
|
✗ |
inline void WeighedLeafConnectedComp::serialize(Archive& ar, |
| 101 |
|
|
const unsigned int version) { |
| 102 |
|
|
using namespace boost::serialization; |
| 103 |
|
|
(void)version; |
| 104 |
|
✗ |
ar& make_nvp("base", base_object<LeafConnectedComp>(*this)); |
| 105 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(weight_); |
| 106 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(p_); |
| 107 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(edges_); |
| 108 |
|
|
} |
| 109 |
|
|
HPP_SERIALIZATION_IMPLEMENT(WeighedLeafConnectedComp); |
| 110 |
|
|
|
| 111 |
|
|
template <typename Archive> |
| 112 |
|
✗ |
inline void Roadmap::serialize(Archive& ar, const unsigned int version) { |
| 113 |
|
|
using namespace boost::serialization; |
| 114 |
|
|
(void)version; |
| 115 |
|
|
// Must deserialize the graph before the connected components (so the base |
| 116 |
|
|
// class). |
| 117 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(graph_); |
| 118 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(weak_); |
| 119 |
|
✗ |
ar& make_nvp("base", base_object<core::Roadmap>(*this)); |
| 120 |
|
|
// ar & BOOST_SERIALIZATION_NVP(histograms_); |
| 121 |
|
✗ |
ar& BOOST_SERIALIZATION_NVP(leafCCs_); |
| 122 |
|
|
} |
| 123 |
|
|
HPP_SERIALIZATION_IMPLEMENT(Roadmap); |
| 124 |
|
|
|
| 125 |
|
|
} // namespace manipulation |
| 126 |
|
|
} // namespace hpp |
| 127 |
|
|
|