forward_skeleton_oarchive.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/serialization/pfto.hpp>
  9. #include <boost/archive/detail/auto_link_archive.hpp>
  10. #include <boost/archive/detail/oserializer.hpp>
  11. #include <boost/archive/detail/interface_oarchive.hpp>
  12. #include <boost/archive/detail/common_oarchive.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_oarchive
  17. : public archive::detail::common_oarchive<Archive>
  18. {
  19. public:
  20. typedef ImplementationArchive implementation_archive_type;
  21. forward_skeleton_oarchive(implementation_archive_type& ar)
  22. : archive::detail::common_oarchive<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_oarchive<Archive>;
  30. friend class archive::save_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 save_override(T const& t, BOOST_PFTO int)
  38. {
  39. archive::save(* this->This(), t);
  40. }
  41. #define BOOST_ARCHIVE_FORWARD_IMPLEMENTATION(T) \
  42. void save_override(T const & 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 save_override(std::string const & t , int)
  56. {
  57. save_override(serialization::collection_size_type(t.size()),0);
  58. }
  59. #undef BOOST_ARCHIVE_FORWARD_IMPLEMENTATION
  60. protected:
  61. /// the actual archive used to serialize the information we actually want to store
  62. implementation_archive_type& implementation_archive;
  63. };
  64. } } } // end namespace boost::mpi::detail
  65. #endif // BOOST_MPI_DETAIL_FORWARD_SKELETON_OARCHIVE_HPP