ossrv_pub/boost_apis/boost/serialization/extended_type_info_typeid.hpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 #ifndef BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP
       
     2 #define BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP
       
     3 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
       
     4 // MS compatible compilers support #pragma once
       
     5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
       
     6 # pragma once
       
     7 #endif
       
     8 
       
     9 // extended_type_info_typeid.hpp: implementation for version that depends
       
    10 // on runtime typing (rtti - typeid) but uses a user specified string
       
    11 // as the portable class identifier.
       
    12 
       
    13 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
       
    14 // Use, modification and distribution is subject to the Boost Software
       
    15 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
       
    16 // http://www.boost.org/LICENSE_1_0.txt)
       
    17 
       
    18 //  See http://www.boost.org for updates, documentation, and revision history.
       
    19 
       
    20 #include <typeinfo>
       
    21 #include <boost/config.hpp>
       
    22 
       
    23 //#include <boost/static_warning.hpp>
       
    24 #include <boost/static_assert.hpp>
       
    25 #include <boost/type_traits/is_polymorphic.hpp>
       
    26 #include <boost/type_traits/is_const.hpp>
       
    27 #include <boost/preprocessor/stringize.hpp>
       
    28 
       
    29 #include <boost/serialization/extended_type_info.hpp>
       
    30 
       
    31 #include <boost/config/abi_prefix.hpp> // must be the last header
       
    32 #ifdef BOOST_MSVC
       
    33 #  pragma warning(push)
       
    34 #  pragma warning(disable : 4251 4231 4660 4275)
       
    35 #endif
       
    36 
       
    37 namespace boost {
       
    38 namespace serialization {
       
    39 
       
    40 namespace detail {
       
    41 
       
    42 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_typeid_0 : 
       
    43     public extended_type_info
       
    44 {
       
    45 private:
       
    46     virtual bool
       
    47     less_than(const extended_type_info &rhs) const;
       
    48 protected:
       
    49     static const extended_type_info *
       
    50     get_derived_extended_type_info(const std::type_info & ti);
       
    51     extended_type_info_typeid_0();
       
    52     // account for bogus gcc warning
       
    53     #if defined(__GNUC__)
       
    54     virtual
       
    55     #endif
       
    56     ~extended_type_info_typeid_0();
       
    57 public:
       
    58     virtual const std::type_info & get_eti() const = 0;
       
    59 };
       
    60 
       
    61 ///////////////////////////////////////////////////////////////////////////////
       
    62 // layer to fold T and const T into the same table entry.
       
    63 template<class T>
       
    64 class extended_type_info_typeid_1 : 
       
    65     public detail::extended_type_info_typeid_0
       
    66 {
       
    67 private:
       
    68     virtual const std::type_info & get_eti() const {
       
    69         return typeid(T);
       
    70     }
       
    71 protected:
       
    72     // private constructor to inhibit any existence other than the 
       
    73     // static one
       
    74     extended_type_info_typeid_1() :
       
    75         detail::extended_type_info_typeid_0()
       
    76     {
       
    77         self_register();    // add type to type table
       
    78     }
       
    79 public:
       
    80     struct is_polymorphic
       
    81     {
       
    82         typedef BOOST_DEDUCED_TYPENAME boost::is_polymorphic<T>::type type;
       
    83         BOOST_STATIC_CONSTANT(bool, value = is_polymorphic::type::value);
       
    84     };
       
    85     static const extended_type_info *
       
    86     get_derived_extended_type_info(const T & t){
       
    87         // note: this implementation - based on usage of typeid (rtti)
       
    88         // only works if the class has at least one virtual function.
       
    89 //      BOOST_STATIC_WARNING(
       
    90 //          static_cast<bool>(is_polymorphic::value)
       
    91 //      );
       
    92         return detail::extended_type_info_typeid_0::get_derived_extended_type_info(typeid(t));
       
    93     }
       
    94     static extended_type_info *
       
    95     get_instance(){
       
    96         static extended_type_info_typeid_1<T> instance;
       
    97         return & instance;
       
    98     }
       
    99     static void
       
   100     export_register(const char * key){
       
   101         get_instance()->key_register(key);
       
   102     }
       
   103 };
       
   104 
       
   105 } // namespace detail
       
   106 
       
   107 ///////////////////////////////////////////////////////////////////////////////
       
   108 template<class T>
       
   109 class extended_type_info_typeid : 
       
   110     public detail::extended_type_info_typeid_1<const T>
       
   111 {};
       
   112 
       
   113 } // namespace serialization
       
   114 } // namespace boost
       
   115 
       
   116 ///////////////////////////////////////////////////////////////////////////////
       
   117 // If no other implementation has been designated as default, 
       
   118 // use this one.  To use this implementation as the default, specify it
       
   119 // before any of the other headers.
       
   120 #ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
       
   121     #define BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
       
   122     namespace boost {
       
   123     namespace serialization {
       
   124     template<class T>
       
   125     struct extended_type_info_impl {
       
   126         typedef BOOST_DEDUCED_TYPENAME 
       
   127             boost::serialization::extended_type_info_typeid<T> type;
       
   128     };
       
   129     } // namespace serialization
       
   130     } // namespace boost
       
   131 #endif
       
   132 
       
   133 #ifdef BOOST_MSVC
       
   134 #pragma warning(pop)
       
   135 #endif
       
   136 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
       
   137 
       
   138 #endif // BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP