5#ifndef __pinocchio_serialization_vector_hpp__
6#define __pinocchio_serialization_vector_hpp__
10#include <boost/version.hpp>
11#include <boost/core/addressof.hpp>
12#include <boost/serialization/nvp.hpp>
13#include <boost/serialization/vector.hpp>
17 namespace serialization
20#if BOOST_VERSION / 100 % 1000 == 58
27 :
public std::pair<const char *, T *>
28 ,
public wrapper_traits<const nvp<T>>
32 : std::pair<const char *, T *>(rhs.first, rhs.second)
37 explicit nvp(
const char * name_, T & t)
39 std::pair<const char *, T *>(name_, boost::addressof(t))
43 const char *
name()
const
49 return *(this->second);
52 const T & const_value()
const
54 return *(this->second);
57 template<
class Archive>
59 Archive & ar,
const unsigned int
62 ar.operator<<(const_value());
64 template<
class Archive>
66 Archive & ar,
const unsigned int
69 ar.operator>>(value());
71 BOOST_SERIALIZATION_SPLIT_MEMBER()
74 template<
class T,
class Allocator>
75 struct nvp<std::vector<T, Allocator>>
76 :
public std::pair<const char *, std::vector<T, Allocator> *>
77 ,
public wrapper_traits<const nvp<std::vector<T, Allocator>>>
81 : std::pair<const char *, std::vector<T, Allocator> *>(rhs.first, rhs.second)
85 typedef typename std::vector<T, Allocator>::const_iterator const_iterator;
86 typedef typename std::vector<T, Allocator>::iterator iterator;
89 explicit nvp(
const char * name_, std::vector<T, Allocator> & t)
91 std::pair<const char *, std::vector<T, Allocator> *>(name_, boost::addressof(t))
95 const char *
name()
const
100 std::vector<T, Allocator> & value()
const
102 return *(this->second);
105 const std::vector<T, Allocator> & const_value()
const
107 return *(this->second);
110 template<
class Archive>
112 Archive & ar,
const unsigned int
115 const size_t count(const_value().size());
116 ar << BOOST_SERIALIZATION_NVP(count);
117 if (!const_value().empty())
119 for (const_iterator hint = const_value().begin(); hint != const_value().end(); ++hint)
121 ar & boost::serialization::make_nvp(
"item", *hint);
126 template<
class Archive>
128 Archive & ar,
const unsigned int
132 ar >> BOOST_SERIALIZATION_NVP(count);
133 value().resize(count);
134 for (iterator hint = value().begin(); hint != value().end(); ++hint)
136 ar >> boost::serialization::make_nvp(
"item", *hint);
140 BOOST_SERIALIZATION_SPLIT_MEMBER()
143 template<
typename Allocator>
144 struct nvp<std::vector<bool, Allocator>>
145 :
public std::pair<const char *, std::vector<bool, Allocator> *>
146 ,
public wrapper_traits<const nvp<std::vector<bool, Allocator>>>
150 : std::pair<const char *, std::vector<bool, Allocator> *>(rhs.first, rhs.second)
154 typedef typename std::vector<bool, Allocator>::const_iterator const_iterator;
155 typedef typename std::vector<bool, Allocator>::iterator iterator;
158 explicit nvp(
const char * name_, std::vector<bool, Allocator> & t)
160 std::pair<const char *, std::vector<bool, Allocator> *>(name_, boost::addressof(t))
164 const char *
name()
const
169 std::vector<bool, Allocator> & value()
const
171 return *(this->second);
174 const std::vector<bool, Allocator> & const_value()
const
176 return *(this->second);
179 template<
class Archive>
181 Archive & ar,
const unsigned int
184 const size_t count(const_value().size());
185 ar << BOOST_SERIALIZATION_NVP(count);
186 if (!const_value().empty())
188 for (const_iterator hint = const_value().begin(); hint != const_value().end(); ++hint)
191 ar & boost::serialization::make_nvp(
"item", v);
196 template<
class Archive>
198 Archive & ar,
const unsigned int
202 ar >> BOOST_SERIALIZATION_NVP(count);
203 value().resize(count);
204 for (iterator hint = value().begin(); hint != value().end(); ++hint)
207 ar >> boost::serialization::make_nvp(
"item", v);
212 BOOST_SERIALIZATION_SPLIT_MEMBER()
217 template<
class T,
class Allocator>
218 inline const fixme::nvp<std::vector<T, Allocator>>
219 make_nvp(
const char * name, std::vector<T, Allocator> & t)
221 return fixme::nvp<std::vector<T, Allocator>>(
name, t);
224 template<
class T,
class Allocator>
225 inline const nvp<std::vector<T, Allocator>>
226 make_nvp(
const char * name, std::vector<T, Allocator> & t)
228 return nvp<std::vector<T, Allocator>>(
name, t);
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.