Commit 2b8f0599 authored by Pierre Fernbach's avatar Pierre Fernbach Committed by Guilhem Saurel
Browse files

Add a serialization version number and define it for all classes

parent 65315995
......@@ -93,4 +93,7 @@ std::vector<Bern<Numeric> > makeBernstein(const unsigned int n) {
return res;
}
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(typename Numeric, curves::Bern<Numeric>)
#endif //_CLASS_BERNSTEIN
......@@ -516,4 +516,8 @@ template <typename Time, typename Numeric, bool Safe, typename Point>
const double bezier_curve<Time, Numeric, Safe, Point>::MARGIN(0.001);
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point),
SINGLE_ARG(curves::bezier_curve<Time, Numeric, Safe, Point>))
#endif //_CLASS_BEZIERCURVE
......@@ -171,4 +171,7 @@ struct constant_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deriv
}; // struct constant_curve
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename Point_derivate),
SINGLE_ARG(curves::constant_curve<Time, Numeric, Safe, Point, Point_derivate>))
#endif // _CLASS_CONSTANTCURVE
......@@ -367,4 +367,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point> {
}
}; // End struct Cubic hermite spline
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point),
SINGLE_ARG(curves::cubic_hermite_spline<Time, Numeric, Safe, Point>))
#endif //_CLASS_CUBICHERMITESPLINE
......@@ -144,4 +144,7 @@ struct curve_abc : std::unary_function<Time, Point>, public serialization::Seria
};
BOOST_SERIALIZATION_ASSUME_ABSTRACT(curve_abc)
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename Point_derivate),
SINGLE_ARG(curves::curve_abc<Time, Numeric, Safe, Point, Point_derivate>))
#endif //_STRUCT_CURVE_ABC
......@@ -309,4 +309,8 @@ struct exact_cubic : public piecewise_curve<Time, Numeric, Safe, Point> {
}
};
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point,
typename T_Point, typename SplineBase),
SINGLE_ARG(curves::exact_cubic<Time, Numeric, Safe, Point, T_Point, SplineBase>))
#endif //_CLASS_EXACTCUBIC
......@@ -183,4 +183,7 @@ BezierFixed evaluateLinear(const BezierLinear& bIn, const X x) {
}
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Numeric, bool Safe),
SINGLE_ARG(curves::linear_variable<Numeric, Safe>))
#endif //_CLASS_LINEAR_VARIABLE
......@@ -608,4 +608,8 @@ const double piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveTy
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point,
typename Point_derivate, typename CurveType),
SINGLE_ARG(curves::piecewise_curve<Time, Numeric, Safe, Point, Point_derivate, CurveType>))
#endif // _CLASS_PIECEWISE_CURVE
......@@ -440,4 +440,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point> {
}; // class polynomial
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point, typename T_Point),
SINGLE_ARG(curves::polynomial<Time, Numeric, Safe, Point, T_Point>))
#endif //_STRUCT_POLYNOMIAL
......@@ -258,4 +258,7 @@ struct SE3Curve : public curve_abc<Time, Numeric, Safe, Eigen::Transform<Numeric
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe),
SINGLE_ARG(curves::SE3Curve<Time, Numeric, Safe>))
#endif // SE3_CURVE_H
......@@ -12,8 +12,29 @@
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/version.hpp>
#include "registeration.hpp"
/* Define the current version number for the serialization
* Must be increased everytime the save() method of a class is modified
* Or when a change is made to register_types()
* */
const unsigned int CURVES_API_VERSION = 1;
#define SINGLE_ARG(...) __VA_ARGS__ // Macro used to be able to put comma in the following macro arguments
// Macro used to define the serialization version of a templated class
#define DEFINE_CLASS_TEMPLATE_VERSION(Template, Type) \
namespace boost { \
namespace serialization { \
template <Template> \
struct version<Type> { \
static constexpr unsigned int value = CURVES_API_VERSION; \
}; \
template <Template> \
constexpr unsigned int version<Type>::value; \
} \
}
namespace curves {
namespace serialization {
struct Serializable {
......
......@@ -213,4 +213,7 @@ struct sinusoidal : public curve_abc<Time, Numeric, Safe, Point> {
}; // struct sinusoidal
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe, typename Point),
SINGLE_ARG(curves::sinusoidal<Time, Numeric, Safe, Point>))
#endif // _CLASS_SINUSOIDALCURVE
......@@ -302,4 +302,7 @@ struct SO3Linear : public curve_abc<Time, Numeric, Safe, matrix3_t, point3_t > {
} // namespace curves
DEFINE_CLASS_TEMPLATE_VERSION(SINGLE_ARG(typename Time, typename Numeric, bool Safe),
SINGLE_ARG(curves::SO3Linear<Time, Numeric, Safe>))
#endif // _STRUCT_SO3_LINEAR_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment