1 // (C) Copyright 2005 Matthias Troyer
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)
7 // Authors: Matthias Troyer
9 #ifndef BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP
10 #define BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP
12 #include <boost/config.hpp>
13 #include <boost/serialization/array.hpp>
15 namespace boost { namespace mpi { namespace detail {
17 /// @brief a minimal output archive, which forwards saving to another archive
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
25 template <class ImplementationArchive>
26 class forward_oprimitive
30 /// the type of the archive to which the saving of primitive types will be forwarded
31 typedef ImplementationArchive implementation_archive_type;
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)
38 /// binary saving is forwarded to the implementation archive
39 void save_binary(const void * address, std::size_t count)
41 implementation_archive.save_binary(address,count);
44 /// saving of arrays is forwarded to the implementation archive
46 void save_array(serialization::array_wrapper<T> const& x, unsigned int file_version )
48 implementation_archive.save_array(x,file_version);
51 typedef typename ImplementationArchive::use_array_optimization use_array_optimization;
53 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
54 friend class archive::save_access;
60 /// saving of primitives is forwarded to the implementation archive
62 void save(const T & t)
64 implementation_archive << t;
68 implementation_archive_type& implementation_archive;
71 } } } // end namespace boost::mpi::detail
73 #endif // BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP