Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:57

0001 // (C) Copyright 2005 Matthias Troyer 
0002 
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 //  Authors: Matthias Troyer
0008 
0009 #ifndef BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP
0010 #define BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP
0011 
0012 #include <boost/config.hpp>
0013 #include <boost/serialization/array.hpp>
0014 
0015 namespace boost { namespace mpi { namespace detail {
0016 
0017 /// @brief a minimal output archive, which forwards saving to another archive
0018 ///
0019 /// This class template is designed to use the saving facilities of another
0020 /// output archive (the "implementation archive", whose type is specified by 
0021 /// the template argument, to handle serialization of primitive types, 
0022 /// while serialization for specific types can be overriden independently 
0023 /// of that archive.
0024 
0025 template <class ImplementationArchive>
0026 class forward_oprimitive
0027 {
0028 public:
0029 
0030     /// the type of the archive to which the saving of primitive types will be forwarded
0031     typedef ImplementationArchive implementation_archive_type;
0032     
0033     /// the constructor takes a reference to the implementation archive used for saving primitve types
0034     forward_oprimitive(implementation_archive_type& ar)
0035      : implementation_archive(ar)
0036     {}
0037 
0038     /// binary saving is forwarded to the implementation archive
0039     void save_binary(const void * address, std::size_t count)
0040     {
0041       implementation_archive.save_binary(address,count);
0042     }
0043     
0044     /// saving of arrays is forwarded to the implementation archive
0045     template<class T>
0046     void save_array(serialization::array_wrapper<T> const& x, unsigned int file_version )
0047     {
0048       implementation_archive.save_array(x,file_version);
0049     }
0050 
0051     typedef typename ImplementationArchive::use_array_optimization use_array_optimization;
0052 
0053 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0054     friend class archive::save_access;
0055 protected:
0056 #else
0057 public:
0058 #endif
0059 
0060     ///  saving of primitives is forwarded to the implementation archive
0061     template<class T>
0062     void save(const T & t)
0063     {
0064       implementation_archive << t;
0065     }
0066 
0067 private:
0068     implementation_archive_type& implementation_archive;
0069 };
0070 
0071 } } } // end namespace boost::mpi::detail
0072 
0073 #endif // BOOST_MPI_DETAIL_FORWARD_OPRIMITIVE_HPP