Merge branch 'develop' of github.com:USCiLab/cereal into develop

This commit is contained in:
Shane Grant
2013-12-20 11:11:25 -08:00
+18 -17
View File
@@ -33,6 +33,9 @@
#include <type_traits>
#include <cstdint>
#include <utility>
#include <unordered_map>
#include <cereal/details/static_object.hpp>
namespace cereal
{
@@ -310,12 +313,9 @@ namespace cereal
//! Holds all registered version information
struct Versions
{
static std::unordered_map<std::size_t, std::uint32_t> mapping;
std::unordered_map<std::size_t, std::uint32_t> mapping;
}; // struct Versions
//! Initialize the mapping
std::unordered_map<std::size_t, std::uint32_t> Versions::mapping = {};
//! Version information class - used in Boost Transition Layer
/*! This is the base case for classes that have not been explicitly
registered */
@@ -339,19 +339,20 @@ namespace cereal
The recommended way of performing versioning in cereal is to implement it yourself
on a class by class basis as required, creating a thin wrapper if you do not have
access to the internals of a class. */
#define CEREAL_CLASS_VERSION(TYPE, VERSION_NUMBER) \
namespace cereal { namespace detail { \
template <> struct Version<TYPE> \
{ \
static const std::uint32_t version = VERSION_NUMBER; \
static Version<TYPE> registerVersion() \
{ \
Versions::mapping.emplace( std::type_index(typeid(TYPE)).hash_code(), VERSION_NUMBER ); \
return {}; \
} \
}; /* end Version */ \
static const auto CEREAL_CLASS_VERSION_REGISTER##TYPE##VERSION_NUMBER = \
Version<TYPE>::registerVersion(); \
#define CEREAL_CLASS_VERSION(TYPE, VERSION_NUMBER) \
namespace cereal { namespace detail { \
template <> struct Version<TYPE> \
{ \
static const std::uint32_t version = VERSION_NUMBER; \
static Version<TYPE> registerVersion() \
{ \
::cereal::detail::StaticObject<Versions>::getInstance().mapping.emplace( \
std::type_index(typeid(TYPE)).hash_code(), VERSION_NUMBER ); \
return {}; \
} \
}; /* end Version */ \
static const auto CEREAL_CLASS_VERSION_REGISTER##TYPE##VERSION_NUMBER = \
Version<TYPE>::registerVersion(); \
} } // end namespaces
} // namespace cereal