Chris@16: // (C) Copyright 2005 Matthias Troyer Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // Authors: Matthias Troyer Chris@16: Chris@16: #ifndef BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP Chris@16: #define BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace mpi { namespace detail { Chris@16: Chris@16: /// @brief a minimal output archive, which forwards saving to another archive Chris@16: /// Chris@16: /// This class template is designed to use the saving facilities of another Chris@16: /// output archive (the "implementation archive", whose type is specified by Chris@16: /// the template argument, to handle serialization of primitive types, Chris@16: /// while serialization for specific types can be overriden independently Chris@16: /// of that archive. Chris@16: Chris@16: template Chris@16: class forward_oprimitive Chris@16: { Chris@16: public: Chris@16: Chris@16: /// the type of the archive to which the saving of primitive types will be forwarded Chris@16: typedef ImplementationArchive implementation_archive_type; Chris@16: Chris@16: /// the constructor takes a reference to the implementation archive used for saving primitve types Chris@16: forward_oprimitive(implementation_archive_type& ar) Chris@16: : implementation_archive(ar) Chris@16: {} Chris@16: Chris@16: /// binary saving is forwarded to the implementation archive Chris@16: void save_binary(const void * address, std::size_t count) Chris@16: { Chris@16: implementation_archive.save_binary(address,count); Chris@16: } Chris@16: Chris@16: /// saving of arrays is forwarded to the implementation archive Chris@16: template Chris@16: void save_array(serialization::array const& x, unsigned int file_version ) Chris@16: { Chris@16: implementation_archive.save_array(x,file_version); Chris@16: } Chris@16: Chris@16: typedef typename ImplementationArchive::use_array_optimization use_array_optimization; Chris@16: Chris@16: #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS Chris@16: friend class archive::save_access; Chris@16: protected: Chris@16: #else Chris@16: public: Chris@16: #endif Chris@16: Chris@16: /// saving of primitives is forwarded to the implementation archive Chris@16: template Chris@16: void save(const T & t) Chris@16: { Chris@16: implementation_archive << t; Chris@16: } Chris@16: Chris@16: private: Chris@16: implementation_archive_type& implementation_archive; Chris@16: }; Chris@16: Chris@16: } } } // end namespace boost::mpi::detail Chris@16: Chris@16: #endif // BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP