epoc32/include/stdapis/boost/serialization/tracking.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/serialization/tracking.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,113 @@
     1.4 +#ifndef BOOST_SERIALIZATION_TRACKING_HPP
     1.5 +#define BOOST_SERIALIZATION_TRACKING_HPP
     1.6 +
     1.7 +// MS compatible compilers support #pragma once
     1.8 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
     1.9 +# pragma once
    1.10 +#endif
    1.11 +
    1.12 +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
    1.13 +// tracking.hpp:
    1.14 +
    1.15 +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
    1.16 +// Use, modification and distribution is subject to the Boost Software
    1.17 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    1.18 +// http://www.boost.org/LICENSE_1_0.txt)
    1.19 +
    1.20 +//  See http://www.boost.org for updates, documentation, and revision history.
    1.21 +
    1.22 +#include <boost/config.hpp>
    1.23 +#include <boost/static_assert.hpp>
    1.24 +#include <boost/mpl/eval_if.hpp>
    1.25 +#include <boost/mpl/identity.hpp>
    1.26 +#include <boost/mpl/int.hpp>
    1.27 +#include <boost/mpl/equal_to.hpp>
    1.28 +#include <boost/mpl/greater.hpp>
    1.29 +#include <boost/mpl/integral_c_tag.hpp>
    1.30 +
    1.31 +#include <boost/type_traits/is_base_and_derived.hpp>
    1.32 +#include <boost/type_traits/is_pointer.hpp>
    1.33 +#include <boost/serialization/level.hpp>
    1.34 +#include <boost/serialization/tracking_enum.hpp>
    1.35 +//#include <boost/serialization/traits.hpp>
    1.36 +
    1.37 +namespace boost {
    1.38 +namespace serialization {
    1.39 +
    1.40 +struct basic_traits;
    1.41 +
    1.42 +// default tracking level
    1.43 +template<class T>
    1.44 +struct tracking_level {
    1.45 +    template<class U>
    1.46 +    struct traits_class_tracking {
    1.47 +        typedef BOOST_DEDUCED_TYPENAME U::tracking type;
    1.48 +    };
    1.49 +    typedef mpl::integral_c_tag tag;
    1.50 +    // note: at least one compiler complained w/o the full qualification
    1.51 +    // on basic traits below
    1.52 +    typedef
    1.53 +        BOOST_DEDUCED_TYPENAME mpl::eval_if<
    1.54 +            is_base_and_derived<boost::serialization::basic_traits, T>,
    1.55 +            traits_class_tracking<T>,
    1.56 +        //else
    1.57 +        BOOST_DEDUCED_TYPENAME mpl::eval_if<
    1.58 +            is_pointer<T>,
    1.59 +            // pointers are not tracked by default
    1.60 +            mpl::int_<track_never>,
    1.61 +        //else
    1.62 +        BOOST_DEDUCED_TYPENAME mpl::eval_if<
    1.63 +            // for primitives
    1.64 +            BOOST_DEDUCED_TYPENAME mpl::equal_to<
    1.65 +                implementation_level<T>,
    1.66 +                mpl::int_<primitive_type> 
    1.67 +            >,
    1.68 +            // is never
    1.69 +            mpl::int_<track_never>,
    1.70 +            // otherwise its selective
    1.71 +            mpl::int_<track_selectivly>
    1.72 +    >  > >::type type;
    1.73 +    BOOST_STATIC_CONSTANT(int, value = tracking_level::type::value);
    1.74 +};
    1.75 +
    1.76 +
    1.77 +template<class T, enum tracking_type L>
    1.78 +inline bool operator>=(tracking_level<T> t, enum tracking_type l)
    1.79 +{
    1.80 +    return t.value >= (int)l;
    1.81 +}
    1.82 +
    1.83 +} // namespace serialization
    1.84 +} // namespace boost
    1.85 +
    1.86 +
    1.87 +// The STATIC_ASSERT is prevents one from setting tracking for a primitive type.  
    1.88 +// This almost HAS to be an error.  Doing this will effect serialization of all 
    1.89 +// char's in your program which is almost certainly what you don't want to do.  
    1.90 +// If you want to track all instances of a given primitive type, You'll have to 
    1.91 +// wrap it in your own type so its not a primitive anymore.  Then it will compile
    1.92 +// without problem.
    1.93 +#define BOOST_CLASS_TRACKING(T, E)           \
    1.94 +namespace boost {                            \
    1.95 +namespace serialization {                    \
    1.96 +template<>                                   \
    1.97 +struct tracking_level< T >                   \
    1.98 +{                                            \
    1.99 +    typedef mpl::integral_c_tag tag;         \
   1.100 +    typedef mpl::int_< E> type;              \
   1.101 +    BOOST_STATIC_CONSTANT(                   \
   1.102 +        int,                                 \
   1.103 +        value = tracking_level::type::value  \
   1.104 +    );                                       \
   1.105 +    /* tracking for a class  */              \
   1.106 +    BOOST_STATIC_ASSERT((                    \
   1.107 +        mpl::greater<                        \
   1.108 +            /* that is a prmitive */         \
   1.109 +            implementation_level< T >,       \
   1.110 +            mpl::int_<primitive_type>        \
   1.111 +        >::value                             \
   1.112 +    ));                                      \
   1.113 +};                                           \
   1.114 +}}
   1.115 +
   1.116 +#endif // BOOST_SERIALIZATION_TRACKING_HPP