| 1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
|---|---|
| 2 | // archive_serializer_map.ipp: |
| 3 | |
| 4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
| 5 | // Distributed under the Boost Software License, Version 1.0. (See |
| 6 | // accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | // See http://www.boost.org for updates, documentation, and revision history. |
| 10 | |
| 11 | ////////////////////////////////////////////////////////////////////// |
| 12 | // implementation of basic_text_iprimitive overrides for the combination |
| 13 | // of template parameters used to implement a text_iprimitive |
| 14 | |
| 15 | #include <boost/config.hpp> |
| 16 | #include <boost/archive/detail/archive_serializer_map.hpp> |
| 17 | #include <boost/archive/detail/basic_serializer_map.hpp> |
| 18 | #include <boost/serialization/singleton.hpp> |
| 19 | |
| 20 | namespace boost { |
| 21 | namespace archive { |
| 22 | namespace detail { |
| 23 | |
| 24 | #ifdef BOOST_MSVC |
| 25 | # pragma warning(push) |
| 26 | # pragma warning(disable : 4511 4512) |
| 27 | #endif |
| 28 | |
| 29 | namespace extra_detail { // anon |
| 30 | template<class Archive> |
| 31 | class map : public basic_serializer_map |
| 32 | {}; |
| 33 | } |
| 34 | |
| 35 | #ifdef BOOST_MSVC |
| 36 | # pragma warning(pop) |
| 37 | #endif |
| 38 | |
| 39 | template<class Archive> |
| 40 | BOOST_ARCHIVE_OR_WARCHIVE_DECL bool |
| 41 | archive_serializer_map<Archive>::insert(const basic_serializer * bs){ |
| 42 | return boost::serialization::singleton< |
| 43 | extra_detail::map<Archive> |
| 44 | >::get_mutable_instance().insert(bs); |
| 45 | } |
| 46 | |
| 47 | template<class Archive> |
| 48 | BOOST_ARCHIVE_OR_WARCHIVE_DECL void |
| 49 | archive_serializer_map<Archive>::erase(const basic_serializer * bs){ |
| 50 | // note: previously this conditional was a runtime assertion with |
| 51 | // BOOST_ASSERT. We've changed it because we've discovered that at |
| 52 | // least one platform is not guaranteed to destroy singletons in |
| 53 | // reverse order of distruction. |
| 54 | if(boost::serialization::singleton< |
| 55 | extra_detail::map<Archive> |
| 56 | >::is_destroyed()) |
| 57 | return; |
| 58 | boost::serialization::singleton< |
| 59 | extra_detail::map<Archive> |
| 60 | >::get_mutable_instance().erase(bs); |
| 61 | } |
| 62 | |
| 63 | template<class Archive> |
| 64 | BOOST_ARCHIVE_OR_WARCHIVE_DECL const basic_serializer * |
| 65 | archive_serializer_map<Archive>::find( |
| 66 | const boost::serialization::extended_type_info & eti |
| 67 | ) { |
| 68 | return boost::serialization::singleton< |
| 69 | extra_detail::map<Archive> |
| 70 | >::get_const_instance().find(eti); |
| 71 | } |
| 72 | |
| 73 | } // namespace detail |
| 74 | } // namespace archive |
| 75 | } // namespace boost |
| 76 |
