1 #ifndef BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP
2 #define BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP
4 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
5 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 // extended_type_info_typeid.hpp: implementation for version that depends
11 // on runtime typing (rtti - typeid) but uses a user specified string
12 // as the portable class identifier.
14 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
15 // Use, modification and distribution is subject to the Boost Software
16 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 // See http://www.boost.org for updates, documentation, and revision history.
24 #include <boost/config.hpp>
26 #include <boost/static_assert.hpp>
27 #include <boost/serialization/static_warning.hpp>
28 #include <boost/type_traits/is_polymorphic.hpp>
29 #include <boost/type_traits/remove_const.hpp>
31 #include <boost/serialization/singleton.hpp>
32 #include <boost/serialization/extended_type_info.hpp>
33 #include <boost/serialization/factory.hpp>
35 #include <boost/config/abi_prefix.hpp> // must be the last header
37 # pragma warning(push)
38 # pragma warning(disable : 4251 4231 4660 4275)
42 namespace serialization
{
45 class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_typeid_0
:
46 public extended_type_info
49 const std::type_info
* m_ti
;
50 extended_type_info_typeid_0();
51 ~extended_type_info_typeid_0();
52 void type_register(const std::type_info
& ti
);
53 void type_unregister();
54 const extended_type_info
*
55 get_extended_type_info(const std::type_info
& ti
) const;
58 is_less_than(const extended_type_info
&rhs
) const;
60 is_equal(const extended_type_info
&rhs
) const;
61 const std::type_info
& get_typeid() const {
69 class extended_type_info_typeid
:
70 public detail::extended_type_info_typeid_0
,
71 public singleton
<extended_type_info_typeid
<T
> >
74 extended_type_info_typeid() :
75 detail::extended_type_info_typeid_0()
77 type_register(typeid(T
));
79 ~extended_type_info_typeid(){
82 // get the eti record for the true type of this record
83 // relying upon standard type info implemenation (rtti)
84 const extended_type_info
*
85 get_derived_extended_type_info(const T
& t
) const {
86 // note: this implementation - based on usage of typeid (rtti)
87 // only does something if the class has at least one virtual function.
88 BOOST_STATIC_WARNING(boost::is_polymorphic
<T
>::value
);
90 detail::extended_type_info_typeid_0::get_extended_type_info(
94 void * construct(unsigned int count
, ...) const{
95 // count up the arguments
100 return factory
<boost::remove_const
<T
>, 0>(ap
);
102 return factory
<boost::remove_const
<T
>, 1>(ap
);
104 return factory
<boost::remove_const
<T
>, 2>(ap
);
106 return factory
<boost::remove_const
<T
>, 3>(ap
);
108 return factory
<boost::remove_const
<T
>, 4>(ap
);
110 assert(false); // too many arguments
111 // throw exception here?
115 void destroy(void const * const /* p */) const {
116 // the only current usage of extended type info is in the
117 // serialization library. The statement below requires
118 // that destructor of type T be public and this creates
119 // a problem for some users. So, for now, comment this
121 //delete static_cast<T const *>(p);
122 // and trap any attempt to invoke this function
127 } // namespace serialization
130 ///////////////////////////////////////////////////////////////////////////////
131 // If no other implementation has been designated as default,
132 // use this one. To use this implementation as the default, specify it
133 // before any of the other headers.
134 #ifndef BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
135 #define BOOST_SERIALIZATION_DEFAULT_TYPE_INFO
137 namespace serialization
{
139 struct extended_type_info_impl
{
140 typedef BOOST_DEDUCED_TYPENAME
141 boost::serialization::extended_type_info_typeid
<T
> type
;
143 } // namespace serialization
150 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
152 #endif // BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_TYPEID_HPP