]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/src/extended_type_info.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // extended_type_info.cpp: implementation for portable version of type_info
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org for updates, documentation, and revision history.
11 #if (defined _MSC_VER) && (_MSC_VER == 1200)
12 # pragma warning (disable : 4786) // too long name, harmless warning
18 #include <boost/assert.hpp>
19 #include <cstddef> // NULL
22 #if defined(BOOST_NO_STDC_NAMESPACE)
23 namespace std
{ using ::strcmp
; }
26 #include <boost/config.hpp> // msvc needs this to suppress warning
28 #include <boost/core/no_exceptions_support.hpp>
30 // it marks our code with proper attributes as being exported when
31 // we're compiling it while marking it import when just the headers
33 #define BOOST_SERIALIZATION_SOURCE
34 #include <boost/serialization/config.hpp>
35 #include <boost/serialization/singleton.hpp>
36 #include <boost/serialization/force_include.hpp>
37 #include <boost/serialization/extended_type_info.hpp>
40 # pragma warning(push)
41 # pragma warning(disable : 4511 4512)
45 namespace serialization
{
52 const extended_type_info
* lhs
,
53 const extended_type_info
* rhs
55 // performance shortcut
58 const char * l
= lhs
->get_key();
59 BOOST_ASSERT(NULL
!= l
);
60 const char * r
= rhs
->get_key();
61 BOOST_ASSERT(NULL
!= r
);
62 // performance shortcut
63 // shortcut to exploit string pooling
66 // for exported types, use the string key so that
67 // multiple instances in different translation units
69 return std::strcmp(l
, r
) < 0;
73 typedef std::multiset
<const extended_type_info
*, key_compare
> ktmap
;
76 # pragma warning(push)
77 # pragma warning(disable : 4511 4512)
80 class extended_type_info_arg
: public extended_type_info
83 is_less_than(const extended_type_info
& /*rhs*/) const {
88 is_equal(const extended_type_info
& /*rhs*/) const {
92 virtual const char * get_debug_info() const {
95 virtual void * construct(unsigned int /*count*/, ...) const{
99 virtual void destroy(void const * const /*p*/) const {
103 extended_type_info_arg(const char * key
) :
104 extended_type_info(0, key
)
107 ~extended_type_info_arg(){
112 # pragma warning(pop)
115 } // namespace detail
117 BOOST_SERIALIZATION_DECL
void
118 extended_type_info::key_register() const{
119 if(NULL
== get_key())
121 singleton
<detail::ktmap
>::get_mutable_instance().insert(this);
124 BOOST_SERIALIZATION_DECL
void
125 extended_type_info::key_unregister() const{
126 if(NULL
== get_key())
128 BOOST_ASSERT(! singleton
<detail::ktmap
>::is_destroyed());
129 if(! singleton
<detail::ktmap
>::is_destroyed()){
130 detail::ktmap
& x
= singleton
<detail::ktmap
>::get_mutable_instance();
131 detail::ktmap::iterator start
= x
.lower_bound(this);
132 detail::ktmap::iterator end
= x
.upper_bound(this);
133 // remove entry in map which corresponds to this type
134 for(;start
!= end
; ++start
){
143 BOOST_SERIALIZATION_DECL
const extended_type_info
*
144 extended_type_info::find(const char *key
) {
145 BOOST_ASSERT(NULL
!= key
);
146 const detail::ktmap
& k
= singleton
<detail::ktmap
>::get_const_instance();
147 const detail::extended_type_info_arg
eti_key(key
);
148 const detail::ktmap::const_iterator it
= k
.find(& eti_key
);
154 BOOST_SERIALIZATION_DECL
155 extended_type_info::extended_type_info(
156 const unsigned int type_info_key
,
159 m_type_info_key(type_info_key
),
164 BOOST_SERIALIZATION_DECL
165 extended_type_info::~extended_type_info(){
168 BOOST_SERIALIZATION_DECL
bool
169 extended_type_info::operator<(const extended_type_info
&rhs
) const {
170 // short cut for a common cases
173 if(m_type_info_key
== rhs
.m_type_info_key
){
174 return is_less_than(rhs
);
176 if(m_type_info_key
< rhs
.m_type_info_key
)
181 BOOST_SERIALIZATION_DECL
bool
182 extended_type_info::operator==(const extended_type_info
&rhs
) const {
183 // short cut for a common cases
186 if(m_type_info_key
!= rhs
.m_type_info_key
){
189 return is_equal(rhs
);
192 } // namespace serialization