archive_serializer_map.ipp 2.3 KB

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