forward_skeleton_iarchive.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // (C) Copyright 2005 Matthias Troyer
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Matthias Troyer
  6. #ifndef BOOST_MPI_DETAIL_FORWARD_SKELETON_IARCHIVE_HPP
  7. #define BOOST_MPI_DETAIL_FORWARD_SKELETON_IARCHIVE_HPP
  8. #include <boost/serialization/pfto.hpp>
  9. #include <boost/archive/detail/auto_link_archive.hpp>
  10. #include <boost/archive/detail/iserializer.hpp>
  11. #include <boost/archive/detail/interface_iarchive.hpp>
  12. #include <boost/archive/detail/common_iarchive.hpp>
  13. #include <boost/serialization/collection_size_type.hpp>
  14. namespace boost { namespace mpi { namespace detail {
  15. template<class Archive, class ImplementationArchive>
  16. class forward_skeleton_iarchive
  17. : public archive::detail::common_iarchive<Archive>
  18. {
  19. public:
  20. typedef ImplementationArchive implementation_archive_type;
  21. forward_skeleton_iarchive(implementation_archive_type& ar)
  22. : archive::detail::common_iarchive<Archive>(archive::no_header),
  23. implementation_archive(ar)
  24. {
  25. }
  26. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  27. public:
  28. #else
  29. friend class archive::detail::interface_iarchive<Archive>;
  30. friend class archive::load_access;
  31. protected:
  32. #endif
  33. // intermediate level to support override of operators
  34. // for templates in the absence of partial function
  35. // template ordering
  36. template<class T>
  37. void load_override(T & t, BOOST_PFTO int)
  38. {
  39. archive::load(* this->This(), t);
  40. }
  41. #define BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(T) \
  42. void load_override(T & t , int) \
  43. { \
  44. implementation_archive >> t; \
  45. }
  46. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_id_optional_type)
  47. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::version_type)
  48. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_id_type)
  49. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_id_reference_type)
  50. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::object_id_type)
  51. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::object_reference_type)
  52. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::tracking_type)
  53. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_name_type)
  54. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(serialization::collection_size_type)
  55. void load_override(std::string & s , int)
  56. {
  57. serialization::collection_size_type length(s.size());
  58. load_override(length,0);
  59. s.resize(length);
  60. }
  61. #undef BOOST_ARCHIVE_FORWARD_IMPLEMENTATION
  62. protected:
  63. /// the actual archive used to serialize the information we actually want to store
  64. implementation_archive_type& implementation_archive;
  65. };
  66. } } } // end namespace boost::mpi::detail
  67. #endif // BOOST_MPI_DETAIL_FORWARD_SKELETON_IARCHIVE_HPP