os/ossrv/ossrv_pub/boost_apis/boost/serialization/version.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
#ifndef BOOST_SERIALIZATION_VERSION_HPP
sl@0
     2
#define BOOST_SERIALIZATION_VERSION_HPP
sl@0
     3
sl@0
     4
// MS compatible compilers support #pragma once
sl@0
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
sl@0
     6
# pragma once
sl@0
     7
#endif
sl@0
     8
sl@0
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
sl@0
    10
// version.hpp:
sl@0
    11
sl@0
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
sl@0
    13
// Use, modification and distribution is subject to the Boost Software
sl@0
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
    15
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    16
sl@0
    17
//  See http://www.boost.org for updates, documentation, and revision history.
sl@0
    18
sl@0
    19
#include <boost/config.hpp>
sl@0
    20
#include <boost/mpl/int.hpp>
sl@0
    21
#include <boost/mpl/eval_if.hpp>
sl@0
    22
#include <boost/mpl/identity.hpp>
sl@0
    23
#include <boost/mpl/integral_c_tag.hpp>
sl@0
    24
sl@0
    25
#include <boost/type_traits/is_base_and_derived.hpp>
sl@0
    26
//#include <boost/serialization/traits.hpp>
sl@0
    27
sl@0
    28
namespace boost { 
sl@0
    29
namespace serialization {
sl@0
    30
sl@0
    31
struct basic_traits;
sl@0
    32
sl@0
    33
// default version number is 0. Override with higher version
sl@0
    34
// when class definition changes.
sl@0
    35
template<class T>
sl@0
    36
struct version
sl@0
    37
{
sl@0
    38
    template<class U>
sl@0
    39
    struct traits_class_version {
sl@0
    40
        typedef BOOST_DEDUCED_TYPENAME U::version type;
sl@0
    41
    };
sl@0
    42
sl@0
    43
    typedef mpl::integral_c_tag tag;
sl@0
    44
    // note: at least one compiler complained w/o the full qualification
sl@0
    45
    // on basic traits below
sl@0
    46
    typedef
sl@0
    47
        BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0
    48
            is_base_and_derived<boost::serialization::basic_traits,T>,
sl@0
    49
            traits_class_version<T>,
sl@0
    50
            mpl::int_<0>
sl@0
    51
        >::type type;
sl@0
    52
    BOOST_STATIC_CONSTANT(unsigned int, value = version::type::value);
sl@0
    53
};
sl@0
    54
sl@0
    55
} // namespace serialization
sl@0
    56
} // namespace boost
sl@0
    57
sl@0
    58
// specify the current version number for the class
sl@0
    59
#define BOOST_CLASS_VERSION(T, N)                                      \
sl@0
    60
namespace boost {                                                      \
sl@0
    61
namespace serialization {                                              \
sl@0
    62
template<>                                                             \
sl@0
    63
struct version<T >                                                     \
sl@0
    64
{                                                                      \
sl@0
    65
    typedef mpl::int_<N> type;                                         \
sl@0
    66
    typedef mpl::integral_c_tag tag;                                   \
sl@0
    67
    BOOST_STATIC_CONSTANT(unsigned int, value = version::type::value); \
sl@0
    68
    /* require that class info saved when versioning is used */        \
sl@0
    69
    /*                                                                 \
sl@0
    70
    BOOST_STATIC_ASSERT((                                              \
sl@0
    71
        mpl::or_<                                                      \
sl@0
    72
            mpl::equal_to<                                             \
sl@0
    73
                mpl::int_<0>,                                          \
sl@0
    74
                mpl::int_<N>                                           \
sl@0
    75
            >,                                                         \
sl@0
    76
            mpl::equal_to<                                             \
sl@0
    77
                implementation_level<T>,                               \
sl@0
    78
                mpl::int_<object_class_info>                           \
sl@0
    79
            >                                                          \
sl@0
    80
        >::value                                                       \
sl@0
    81
    ));                                                                \
sl@0
    82
    */                                                                 \
sl@0
    83
};                                                                     \
sl@0
    84
}                                                                      \
sl@0
    85
}
sl@0
    86
sl@0
    87
#endif // BOOST_SERIALIZATION_VERSION_HPP