• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_HPP
2 #define BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8 
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // extended_type_info.hpp: interface for portable version of type_info
11 
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16 
17 //  See http://www.boost.org for updates, documentation, and revision history.
18 
19 // for now, extended type info is part of the serialization libraries
20 // this could change in the future.
21 #include <cstdarg>
22 #include <boost/assert.hpp>
23 #include <cstddef> // NULL
24 #include <boost/config.hpp>
25 #include <boost/noncopyable.hpp>
26 #include <boost/mpl/bool.hpp>
27 
28 #include <boost/serialization/config.hpp>
29 #include <boost/config/abi_prefix.hpp> // must be the last header
30 #ifdef BOOST_MSVC
31 #  pragma warning(push)
32 #  pragma warning(disable : 4251 4231 4660 4275)
33 #endif
34 
35 #define BOOST_SERIALIZATION_MAX_KEY_SIZE 128
36 
37 namespace boost {
38 namespace serialization {
39 
40 namespace void_cast_detail{
41     class void_caster;
42 }
43 
44 class BOOST_SYMBOL_VISIBLE extended_type_info :
45     private boost::noncopyable
46 {
47 private:
48     friend class boost::serialization::void_cast_detail::void_caster;
49 
50     // used to uniquely identify the type of class derived from this one
51     // so that different derivations of this class can be simultaneously
52     // included in implementation of sets and maps.
53     const unsigned int m_type_info_key;
54     virtual bool is_less_than(const extended_type_info & /*rhs*/) const = 0;
55     virtual bool is_equal(const extended_type_info & /*rhs*/) const = 0;
56     const char * m_key;
57 
58 protected:
59     BOOST_SERIALIZATION_DECL void key_unregister() const;
60     BOOST_SERIALIZATION_DECL void key_register() const;
61     // this class can't be used as is. It's just the
62     // common functionality for all type_info replacement
63     // systems.  Hence, make these protected
64     BOOST_SERIALIZATION_DECL extended_type_info(
65         const unsigned int type_info_key,
66         const char * key
67     );
68     virtual BOOST_SERIALIZATION_DECL ~extended_type_info();
69 public:
get_key() const70     const char * get_key() const {
71         return m_key;
72     }
73     virtual const char * get_debug_info() const = 0;
74     BOOST_SERIALIZATION_DECL bool operator<(const extended_type_info &rhs) const;
75     BOOST_SERIALIZATION_DECL bool operator==(const extended_type_info &rhs) const;
operator !=(const extended_type_info & rhs) const76     bool operator!=(const extended_type_info &rhs) const {
77         return !(operator==(rhs));
78     }
79     // note explicit "export" of static function to work around
80     // gcc 4.5 mingw error
81     static BOOST_SERIALIZATION_DECL const extended_type_info *
82     find(const char *key);
83     // for plugins
84     virtual void * construct(unsigned int /*count*/ = 0, ...) const = 0;
85     virtual void destroy(void const * const /*p*/) const = 0;
86 };
87 
88 template<class T>
89 struct guid_defined : boost::mpl::false_ {};
90 
91 namespace ext {
92     template <typename T>
93     struct guid_impl
94     {
callboost::serialization::ext::guid_impl95         static inline const char * call()
96         {
97             return NULL;
98         }
99     };
100 }
101 
102 template<class T>
guid()103 inline const char * guid(){
104     return ext::guid_impl<T>::call();
105 }
106 
107 } // namespace serialization
108 } // namespace boost
109 
110 #ifdef BOOST_MSVC
111 #pragma warning(pop)
112 #endif
113 
114 #include <boost/config/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
115 
116 #endif // BOOST_SERIALIZATION_EXTENDED_TYPE_INFO_HPP
117