Commit 7c455b65 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

Serialization: add macro to define API version

parent 074e3ab1
......@@ -140,4 +140,6 @@ struct ContactModelTpl : public serialization::Serializable<ContactModelTpl<_Sca
} // namespace scenario
} // namespace multicontact_api
DEFINE_CLASS_TEMPLATE_VERSION(typename Scalar, multicontact_api::scenario::ContactModelTpl<Scalar>)
#endif // ifndef __multicontact_api_scenario_contact_model_planar_hpp__
......@@ -88,4 +88,6 @@ struct ContactPatchTpl : public serialization::Serializable<ContactPatchTpl<_Sca
} // namespace scenario
} // namespace multicontact_api
DEFINE_CLASS_TEMPLATE_VERSION(typename Scalar, multicontact_api::scenario::ContactPatchTpl<Scalar>)
#endif // __multicontact_api_scenario_contact_patch_hpp__
......@@ -699,4 +699,6 @@ struct ContactPhaseTpl : public serialization::Serializable<ContactPhaseTpl<_Sca
} // namespace scenario
} // namespace multicontact_api
DEFINE_CLASS_TEMPLATE_VERSION(typename Scalar, multicontact_api::scenario::ContactPhaseTpl<Scalar>)
#endif // CONTACTPHASE_HPP
......@@ -1248,4 +1248,7 @@ struct ContactSequenceTpl : public serialization::Serializable<ContactSequenceTp
} // namespace scenario
} // namespace multicontact_api
DEFINE_CLASS_TEMPLATE_VERSION(typename Scalar, multicontact_api::scenario::ContactSequenceTpl<Scalar>)
#endif // __multicontact_api_scenario_contact_sequence_hpp__
......@@ -13,6 +13,22 @@
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/version.hpp>
const unsigned int API_VERSION = 1; // must be increased everytime the save() method of a class is modified
// 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 = API_VERSION; \
}; \
template <Template> \
constexpr unsigned int version<Type>::value; \
} \
}
namespace multicontact_api {
namespace serialization {
......
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