sl@0: #ifndef BOOST_SERIALIZATION_LEVEL_HPP
sl@0: #define BOOST_SERIALIZATION_LEVEL_HPP
sl@0: 
sl@0: // MS compatible compilers support #pragma once
sl@0: #if defined(_MSC_VER) && (_MSC_VER >= 1020)
sl@0: # pragma once
sl@0: #endif
sl@0: 
sl@0: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
sl@0: // level.hpp:
sl@0: 
sl@0: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
sl@0: // Use, modification and distribution is subject to the Boost Software
sl@0: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0: // http://www.boost.org/LICENSE_1_0.txt)
sl@0: 
sl@0: //  See http://www.boost.org for updates, documentation, and revision history.
sl@0: 
sl@0: #include <boost/config.hpp>
sl@0: #include <boost/detail/workaround.hpp>
sl@0: 
sl@0: #include <boost/type_traits/is_fundamental.hpp>
sl@0: #include <boost/type_traits/is_enum.hpp>
sl@0: #include <boost/type_traits/is_array.hpp>
sl@0: #include <boost/type_traits/is_class.hpp>
sl@0: #include <boost/type_traits/is_base_and_derived.hpp>
sl@0: 
sl@0: #include <boost/mpl/eval_if.hpp>
sl@0: #include <boost/mpl/int.hpp>
sl@0: #include <boost/mpl/integral_c.hpp>
sl@0: #include <boost/mpl/integral_c_tag.hpp>
sl@0: #include <boost/mpl/aux_/nttp_decl.hpp>
sl@0: 
sl@0: #include <boost/serialization/level_enum.hpp>
sl@0: 
sl@0: namespace boost {
sl@0: namespace serialization {
sl@0: 
sl@0: struct basic_traits;
sl@0: 
sl@0: // default serialization implementation level
sl@0: template<class T>
sl@0: struct implementation_level {
sl@0:     template<class U>
sl@0:     struct traits_class_level {
sl@0:         typedef  BOOST_DEDUCED_TYPENAME U::level type;
sl@0:     };
sl@0: 
sl@0:     typedef mpl::integral_c_tag tag;
sl@0:     // note: at least one compiler complained w/o the full qualification
sl@0:     // on basic traits below
sl@0:     typedef
sl@0:         BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0:             is_base_and_derived<boost::serialization::basic_traits, T>,
sl@0:             traits_class_level<T>,
sl@0:         //else
sl@0:         BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0:             is_fundamental<T>,
sl@0:             mpl::int_<primitive_type>,
sl@0:         //else
sl@0:         BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0:             is_class<T>,
sl@0:             mpl::int_<object_class_info>,
sl@0:         //else
sl@0:         BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0:             is_array<T>,
sl@0:             #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
sl@0:                 mpl::int_<not_serializable>,
sl@0:             #else
sl@0:                 mpl::int_<object_serializable>,
sl@0:             #endif
sl@0:         //else
sl@0:         BOOST_DEDUCED_TYPENAME mpl::eval_if<
sl@0:             is_enum<T>,
sl@0:             //#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x560))
sl@0:             //    mpl::int_<not_serializable>,
sl@0:             //#else
sl@0:                 mpl::int_<primitive_type>,
sl@0:             //#endif
sl@0:         //else
sl@0:             mpl::int_<not_serializable>
sl@0:         >
sl@0:         >
sl@0:         >
sl@0:         >
sl@0:         >::type type;
sl@0:         // vc 7.1 doesn't like enums here
sl@0:     BOOST_STATIC_CONSTANT(int, value = implementation_level::type::value);
sl@0: };
sl@0: 
sl@0: 
sl@0: template<class T, BOOST_MPL_AUX_NTTP_DECL(int, L) >
sl@0: inline bool operator>=(implementation_level<T> t, enum level_type l)
sl@0: {
sl@0:     return t.value >= (int)l;
sl@0: }
sl@0: 
sl@0: } // namespace serialization
sl@0: } // namespace boost
sl@0: 
sl@0: // specify the level of serialization implementation for the class
sl@0: // require that class info saved when versioning is used
sl@0: #define BOOST_CLASS_IMPLEMENTATION(T, E)                 \
sl@0:     namespace boost {                                    \
sl@0:     namespace serialization {                            \
sl@0:     template <>                                          \
sl@0:     struct implementation_level< T >                     \
sl@0:     {                                                    \
sl@0:         typedef mpl::integral_c_tag tag;                 \
sl@0:         typedef mpl::int_< E > type;                     \
sl@0:         BOOST_STATIC_CONSTANT(                           \
sl@0:             int,                                         \
sl@0:             value = implementation_level::type::value    \
sl@0:         );                                               \
sl@0:     };                                                   \
sl@0:     }                                                    \
sl@0:     }
sl@0:     /**/
sl@0: 
sl@0: #endif // BOOST_SERIALIZATION_LEVEL_HPP