sl@0: #ifndef BOOST_SERIALIZATION_TRACKING_HPP sl@0: #define BOOST_SERIALIZATION_TRACKING_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: // tracking.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 sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: //#include sl@0: sl@0: namespace boost { sl@0: namespace serialization { sl@0: sl@0: struct basic_traits; sl@0: sl@0: // default tracking level sl@0: template sl@0: struct tracking_level { sl@0: template sl@0: struct traits_class_tracking { sl@0: typedef BOOST_DEDUCED_TYPENAME U::tracking type; 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, sl@0: traits_class_tracking, sl@0: //else sl@0: BOOST_DEDUCED_TYPENAME mpl::eval_if< sl@0: is_pointer, sl@0: // pointers are not tracked by default sl@0: mpl::int_, sl@0: //else sl@0: BOOST_DEDUCED_TYPENAME mpl::eval_if< sl@0: // for primitives sl@0: BOOST_DEDUCED_TYPENAME mpl::equal_to< sl@0: implementation_level, sl@0: mpl::int_ sl@0: >, sl@0: // is never sl@0: mpl::int_, sl@0: // otherwise its selective sl@0: mpl::int_ sl@0: > > >::type type; sl@0: BOOST_STATIC_CONSTANT(int, value = tracking_level::type::value); sl@0: }; sl@0: sl@0: sl@0: template sl@0: inline bool operator>=(tracking_level t, enum tracking_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: sl@0: // The STATIC_ASSERT is prevents one from setting tracking for a primitive type. sl@0: // This almost HAS to be an error. Doing this will effect serialization of all sl@0: // char's in your program which is almost certainly what you don't want to do. sl@0: // If you want to track all instances of a given primitive type, You'll have to sl@0: // wrap it in your own type so its not a primitive anymore. Then it will compile sl@0: // without problem. sl@0: #define BOOST_CLASS_TRACKING(T, E) \ sl@0: namespace boost { \ sl@0: namespace serialization { \ sl@0: template<> \ sl@0: struct tracking_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 = tracking_level::type::value \ sl@0: ); \ sl@0: /* tracking for a class */ \ sl@0: BOOST_STATIC_ASSERT(( \ sl@0: mpl::greater< \ sl@0: /* that is a prmitive */ \ sl@0: implementation_level< T >, \ sl@0: mpl::int_ \ sl@0: >::value \ sl@0: )); \ sl@0: }; \ sl@0: }} sl@0: sl@0: #endif // BOOST_SERIALIZATION_TRACKING_HPP