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
21 #if BOOST_VERSION / 100 % 1000 == 58 28 public std::pair<const char *, T *>,
29 public wrapper_traits<const nvp< T > >
32 nvp(
const nvp & rhs) :
33 std::pair<const char *, T *>(rhs.first, rhs.second)
36 explicit nvp(
const char * name_, T & t) :
38 std::pair<const char *, T *>(name_,
boost::addressof(t))
41 const char *
name()
const {
45 return *(this->second);
48 const T & const_value()
const {
49 return *(this->second);
52 template<
class Archive>
57 ar.operator<<(const_value());
59 template<
class Archive>
64 ar.operator>>(value());
66 BOOST_SERIALIZATION_SPLIT_MEMBER()
70 template<
class T,
class Allocator>
71 struct nvp< std::vector<T,Allocator> > :
72 public std::pair<const char *, std::vector<T,Allocator> *>,
73 public wrapper_traits<const nvp< std::vector<T,Allocator> > >
76 nvp(
const nvp & rhs) :
77 std::pair<const char *, std::vector<T,Allocator> *>(rhs.first, rhs.second)
80 typedef typename std::vector<T,Allocator>::const_iterator const_iterator;
81 typedef typename std::vector<T,Allocator>::iterator iterator;
84 explicit nvp(
const char * name_, std::vector<T,Allocator> & t) :
86 std::pair<const char *, std::vector<T,Allocator> *>(name_,
boost::addressof(t))
89 const char *
name()
const {
93 std::vector<T,Allocator> & value()
const {
94 return *(this->second);
97 const std::vector<T,Allocator> & const_value()
const {
98 return *(this->second);
101 template<
class Archive>
102 void save(Archive & ar,
106 const size_t count(const_value().size());
107 ar << BOOST_SERIALIZATION_NVP(count);
108 if (!const_value().empty())
110 for(const_iterator hint = const_value().begin();
111 hint != const_value().end(); ++hint)
113 ar & boost::serialization::make_nvp(
"item", *hint);
118 template<
class Archive>
119 void load(Archive & ar,
124 ar >> BOOST_SERIALIZATION_NVP(count);
125 value().resize(count);
126 for(iterator hint = value().begin();
127 hint != value().end(); ++hint)
129 ar >> boost::serialization::make_nvp(
"item", *hint);
133 BOOST_SERIALIZATION_SPLIT_MEMBER()
136 template<
typename Allocator>
137 struct nvp< std::vector<bool,Allocator> > :
138 public std::pair<const char *, std::vector<bool,Allocator> *>,
139 public wrapper_traits<const nvp< std::vector<bool,Allocator> > >
142 nvp(
const nvp & rhs) :
143 std::pair<const char *, std::vector<bool,Allocator> *>(rhs.first, rhs.second)
146 typedef typename std::vector<bool,Allocator>::const_iterator const_iterator;
147 typedef typename std::vector<bool,Allocator>::iterator iterator;
150 explicit nvp(
const char * name_, std::vector<bool,Allocator> & t) :
152 std::pair<const char *, std::vector<bool,Allocator> *>(name_,
boost::addressof(t))
155 const char *
name()
const {
159 std::vector<bool,Allocator> & value()
const {
160 return *(this->second);
163 const std::vector<bool,Allocator> & const_value()
const {
164 return *(this->second);
167 template<
class Archive>
168 void save(Archive & ar,
172 const size_t count(const_value().size());
173 ar << BOOST_SERIALIZATION_NVP(count);
174 if (!const_value().empty())
176 for(const_iterator hint = const_value().begin();
177 hint != const_value().end(); ++hint)
180 ar & boost::serialization::make_nvp(
"item", v);
185 template<
class Archive>
186 void load(Archive & ar,
191 ar >> BOOST_SERIALIZATION_NVP(count);
192 value().resize(count);
193 for(iterator hint = value().begin();
194 hint != value().end(); ++hint)
197 ar >> boost::serialization::make_nvp(
"item", v);
202 BOOST_SERIALIZATION_SPLIT_MEMBER()
208 template<
class T,
class Allocator>
209 inline const fixme::nvp< std::vector<T,Allocator> >
210 make_nvp(
const char * name, std::vector<T,Allocator> & t)
212 return fixme::nvp< std::vector<T,Allocator> >(name, t);
215 template<
class T,
class Allocator>
216 inline const nvp< std::vector<T,Allocator> >
217 make_nvp(
const char * name, std::vector<T,Allocator> & t)
219 return nvp< std::vector<T,Allocator> >(name, t);
226 #endif // ifndef __pinocchio_serialization_vector_hpp__
std::string name(const LieGroupGenericTpl< LieGroupCollection > &lg)
Visit a LieGroupVariant to get the name of it.