forward_skeleton_oarchive.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_OARCHIVE_HPP
  7. #define BOOST_MPI_DETAIL_FORWARD_SKELETON_OARCHIVE_HPP
  8. #include <boost/archive/detail/auto_link_archive.hpp>
  9. #include <boost/archive/detail/oserializer.hpp>
  10. #include <boost/archive/detail/interface_oarchive.hpp>
  11. #include <boost/archive/detail/common_oarchive.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_oarchive
  16. : public archive::detail::common_oarchive<Archive>
  17. {
  18. public:
  19. typedef ImplementationArchive implementation_archive_type;
  20. forward_skeleton_oarchive(implementation_archive_type& ar)
  21. : archive::detail::common_oarchive<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_oarchive<Archive>;
  29. friend class archive::save_access;
  30. protected:
  31. #endif
  32. template<class T>
  33. void save_override(T const& t)
  34. {
  35. archive::save(* this->This(), t);
  36. }
  37. #define BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(T) \
  38. void save_override(T const & 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 save_override(std::string const & t)
  52. {
  53. save_override(serialization::collection_size_type(t.size()));
  54. }
  55. #undef BOOST_ARCHIVE_FORWARD_IMPLEMENTATION
  56. protected:
  57. /// the actual archive used to serialize the information we actually want to store
  58. implementation_archive_type& implementation_archive;
  59. };
  60. } } } // end namespace boost::mpi::detail
  61. #endif // BOOST_MPI_DETAIL_FORWARD_SKELETON_OARCHIVE_HPP