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