]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright 2005 Matthias Troyer |
2 | ||
3 | // Use, modification and distribution is subject to the Boost Software | |
4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
5 | // http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | // Authors: Matthias Troyer | |
8 | ||
9 | #ifndef BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP | |
10 | #define BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP | |
11 | ||
12 | #include <boost/config.hpp> | |
13 | #include <boost/serialization/array.hpp> | |
14 | ||
15 | namespace boost { namespace mpi { namespace detail { | |
16 | ||
17 | /// @brief a minimal output archive, which forwards saving to another archive | |
18 | /// | |
19 | /// This class template is designed to use the saving facilities of another | |
20 | /// output archive (the "implementation archive", whose type is specified by | |
21 | /// the template argument, to handle serialization of primitive types, | |
22 | /// while serialization for specific types can be overriden independently | |
23 | /// of that archive. | |
24 | ||
25 | template <class ImplementationArchive> | |
26 | class forward_oprimitive | |
27 | { | |
28 | public: | |
29 | ||
30 | /// the type of the archive to which the saving of primitive types will be forwarded | |
31 | typedef ImplementationArchive implementation_archive_type; | |
32 | ||
33 | /// the constructor takes a reference to the implementation archive used for saving primitve types | |
34 | forward_oprimitive(implementation_archive_type& ar) | |
35 | : implementation_archive(ar) | |
36 | {} | |
37 | ||
38 | /// binary saving is forwarded to the implementation archive | |
39 | void save_binary(const void * address, std::size_t count) | |
40 | { | |
41 | implementation_archive.save_binary(address,count); | |
42 | } | |
43 | ||
44 | /// saving of arrays is forwarded to the implementation archive | |
45 | template<class T> | |
46 | void save_array(serialization::array_wrapper<T> const& x, unsigned int file_version ) | |
47 | { | |
48 | implementation_archive.save_array(x,file_version); | |
49 | } | |
50 | ||
51 | typedef typename ImplementationArchive::use_array_optimization use_array_optimization; | |
52 | ||
53 | #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS | |
54 | friend class archive::save_access; | |
55 | protected: | |
56 | #else | |
57 | public: | |
58 | #endif | |
59 | ||
60 | /// saving of primitives is forwarded to the implementation archive | |
61 | template<class T> | |
62 | void save(const T & t) | |
63 | { | |
64 | implementation_archive << t; | |
65 | } | |
66 | ||
67 | private: | |
68 | implementation_archive_type& implementation_archive; | |
69 | }; | |
70 | ||
71 | } } } // end namespace boost::mpi::detail | |
72 | ||
73 | #endif // BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP |