File indexing completed on 2025-01-18 09:40:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_MPI_PACKED_OARCHIVE_HPP
0019 #define BOOST_MPI_PACKED_OARCHIVE_HPP
0020
0021 #include <boost/mpi/datatype.hpp>
0022 #include <boost/archive/basic_archive.hpp>
0023 #include <boost/archive/detail/auto_link_archive.hpp>
0024 #include <boost/archive/detail/common_oarchive.hpp>
0025 #include <boost/mpi/detail/packed_oprimitive.hpp>
0026 #include <boost/mpi/detail/binary_buffer_oprimitive.hpp>
0027 #include <boost/serialization/string.hpp>
0028 #include <boost/serialization/collection_size_type.hpp>
0029 #include <boost/serialization/item_version_type.hpp>
0030
0031 namespace boost { namespace mpi {
0032
0033 #ifdef BOOST_MPI_HOMOGENEOUS
0034 typedef binary_buffer_oprimitive oprimitive;
0035 #else
0036 typedef packed_oprimitive oprimitive;
0037 #endif
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 class BOOST_MPI_DECL packed_oarchive
0049 : public oprimitive
0050 , public archive::detail::common_oarchive<packed_oarchive>
0051 {
0052 public:
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 packed_oarchive( MPI_Comm const & comm, buffer_type & b, unsigned int flags = boost::archive::no_header)
0071 : oprimitive(b,comm),
0072 archive::detail::common_oarchive<packed_oarchive>(flags)
0073 {}
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 packed_oarchive ( MPI_Comm const & comm, unsigned int flags = boost::archive::no_header)
0089 : oprimitive(internal_buffer_,comm),
0090 archive::detail::common_oarchive<packed_oarchive>(flags)
0091 {}
0092
0093
0094 template<class T>
0095 void save_override(T const& x, mpl::false_)
0096 {
0097 archive::detail::common_oarchive<packed_oarchive>::save_override(x);
0098 }
0099
0100
0101 template<class T>
0102 void save_override(T const& x, mpl::true_)
0103 {
0104 oprimitive::save(x);
0105 }
0106
0107
0108 template<class T>
0109 void save_override(T const& x)
0110 {
0111 typedef typename mpl::apply1<use_array_optimization,T>::type use_optimized;
0112 save_override(x, use_optimized());
0113 }
0114
0115
0116 void save_override(const archive::class_id_optional_type & ){}
0117
0118
0119 void save_override(const archive::class_name_type & t){
0120 const std::string s(t);
0121 * this->This() << s;
0122 }
0123
0124 void save_override(const archive::class_id_type & t){
0125 const boost::int_least16_t x = t;
0126 * this->This() << x;
0127 }
0128
0129 void save_override(const archive::version_type & t){
0130 const boost::int_least8_t x = t;
0131 * this->This() << x;
0132 }
0133 private:
0134
0135
0136 buffer_type internal_buffer_;
0137 };
0138
0139 } }
0140
0141
0142 BOOST_SERIALIZATION_REGISTER_ARCHIVE(boost::mpi::packed_oarchive)
0143 BOOST_SERIALIZATION_USE_ARRAY_OPTIMIZATION(boost::mpi::packed_oarchive)
0144
0145
0146
0147 #endif