Skip to content
Snippets Groups Projects
Commit 497a4151 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

[Serialization] add ConnectedComponent

parent 0f2ea63d
No related branches found
No related tags found
No related merge requests found
......@@ -55,8 +55,11 @@ class HPP_MANIPULATION_DLLAPI ConnectedComponent : public core::ConnectedCompone
private:
bool check () const;
GraphStates_t graphStateMap_;
RoadmapPtr_t roadmap_;
// a RoadmapWkPtr_t so that memory can be released ?
RoadmapWkPtr_t roadmap_;
static RoadmapNodes_t empty_;
HPP_SERIALIZABLE();
}; // class ConnectedComponent
} // namespace manipulation
} // namespace hpp
......
......@@ -42,7 +42,7 @@ struct archive_graph_wrapper {
} // namespace hpp
BOOST_CLASS_EXPORT_KEY(hpp::manipulation::RoadmapNode)
BOOST_CLASS_EXPORT_KEY(hpp::manipulation::LeafConnectedComp)
BOOST_CLASS_EXPORT_KEY(hpp::manipulation::ConnectedComponent)
BOOST_CLASS_EXPORT_KEY(hpp::manipulation::WeighedLeafConnectedComp)
BOOST_CLASS_EXPORT_KEY(hpp::manipulation::Roadmap)
......
......@@ -24,13 +24,14 @@
#include <pinocchio/serialization/eigen.hpp>
#include <hpp/util/serialization.hh>
#include <hpp/manipulation/device.hh>
#include <hpp/manipulation/leaf-connected-comp.hh>
#include <hpp/manipulation/roadmap-node.hh>
#include <hpp/manipulation/roadmap.hh>
#include <hpp/manipulation/serialization.hh>
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::RoadmapNode)
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::LeafConnectedComp)
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::ConnectedComponent)
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::WeighedLeafConnectedComp)
BOOST_CLASS_EXPORT_IMPLEMENT(hpp::manipulation::Roadmap)
......@@ -49,6 +50,24 @@ inline void RoadmapNode::serialize(Archive& ar, const unsigned int version)
}
HPP_SERIALIZATION_IMPLEMENT(RoadmapNode);
template <typename Archive>
inline void ConnectedComponent::serialize(Archive& ar, const unsigned int version)
{
using namespace boost::serialization;
(void) version;
ar & make_nvp("base", base_object<core::ConnectedComponent>(*this));
ar & BOOST_SERIALIZATION_NVP(roadmap_);
if (!Archive::is_saving::value) {
RoadmapPtr_t roadmap = roadmap_.lock();
for (const core::NodePtr_t& node : nodes()) {
const RoadmapNodePtr_t& n = static_cast <const RoadmapNodePtr_t> (node);
graphStateMap_[roadmap->getState(n)].push_back(n);
}
}
//ar & BOOST_SERIALIZATION_NVP(graphStateMap_);
}
HPP_SERIALIZATION_IMPLEMENT(ConnectedComponent);
template <typename Archive>
inline void LeafConnectedComp::serialize(Archive& ar, const unsigned int version)
{
......@@ -81,11 +100,12 @@ inline void Roadmap::serialize(Archive& ar, const unsigned int version)
{
using namespace boost::serialization;
(void) version;
// Must deserialize the graph before the connected components (so the base class).
ar & BOOST_SERIALIZATION_NVP(graph_);
ar & BOOST_SERIALIZATION_NVP(weak_);
ar & make_nvp("base", base_object<core::Roadmap>(*this));
//ar & BOOST_SERIALIZATION_NVP(histograms_);
ar & BOOST_SERIALIZATION_NVP(graph_);
ar & BOOST_SERIALIZATION_NVP(leafCCs_);
ar & BOOST_SERIALIZATION_NVP(weak_);
}
HPP_SERIALIZATION_IMPLEMENT(Roadmap);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment