forward_skeleton_iarchive.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/archive/detail/auto_link_archive.hpp>
  9. #include <boost/archive/detail/iserializer.hpp>
  10. #include <boost/archive/detail/interface_iarchive.hpp>
  11. #include <boost/archive/detail/common_iarchive.hpp>
  12. #include <boost/serialization/collection_size_type.hpp>
  13. namespace boost { namespace mpi { namespace detail {
  14. template<class Archive, class ImplementationArchive>
  15. class forward_skeleton_iarchive
  16. : public archive::detail::common_iarchive<Archive>
  17. {
  18. public:
  19. typedef ImplementationArchive implementation_archive_type;
  20. forward_skeleton_iarchive(implementation_archive_type& ar)
  21. : archive::detail::common_iarchive<Archive>(archive::no_header),
  22. implementation_archive(ar)
  23. {
  24. }
  25. #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  26. public:
  27. #else
  28. friend class archive::detail::interface_iarchive<Archive>;
  29. friend class archive::load_access;
  30. protected:
  31. #endif
  32. template<class T>
  33. void load_override(T & t)
  34. {
  35. archive::load(* this->This(), t);
  36. }
  37. #define BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(T) \
  38. void load_override(T & t) \
  39. { \
  40. implementation_archive >> t; \
  41. }
  42. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_id_optional_type)
  43. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::version_type)
  44. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_id_type)
  45. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_id_reference_type)
  46. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::object_id_type)
  47. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::object_reference_type)
  48. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::tracking_type)
  49. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(archive::class_name_type)
  50. BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(serialization::collection_size_type)
  51. void load_override(std::string & s)
  52. {
  53. serialization::collection_size_type length(s.size());
  54. load_override(length);
  55. s.resize(length);
  56. }
  57. #undef BOOST_ARCHIVE_FORWARD_IMPLEMENTATION
  58. protected:
  59. /// the actual archive used to serialize the information we actually want to store
  60. implementation_archive_type& implementation_archive;
  61. };
  62. } } } // end namespace boost::mpi::detail
  63. #endif // BOOST_MPI_DETAIL_FORWARD_SKELETON_IARCHIVE_HPP