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 #include <boost/serialization/array.hpp>
0010 
0011 #ifndef BOOST_MPI_DETAIL_FORWARD_IPRIMITIVE_HPP
0012 #define BOOST_MPI_DETAIL_FORWARD_IPRIMITIVE_HPP
0013 
0014 namespace boost { namespace mpi { namespace detail {
0015 
0016 /// @brief a minimal input archive, which forwards reading to another archive
0017 ///
0018 /// This class template is designed to use the loading facilities of another
0019 /// input archive (the "implementation archive", whose type is specified by 
0020 /// the template argument, to handle serialization of primitive types, 
0021 /// while serialization for specific types can be overriden independently 
0022 /// of that archive.
0023 
0024 template <class ImplementationArchive>
0025 class forward_iprimitive
0026 {
0027 public:
0028 
0029     /// the type of the archive to which the loading of primitive types will be forwarded
0030     typedef ImplementationArchive implementation_archive_type;
0031 
0032     /// the constructor takes a reference to the implementation archive used for loading primitve types
0033     forward_iprimitive(implementation_archive_type& ar)
0034      : implementation_archive(ar)
0035     {}
0036 
0037     /// binary loading is forwarded to the implementation archive
0038     void load_binary(void * address, std::size_t count )
0039     {
0040       implementation_archive.load_binary(address,count);
0041     }
0042     
0043     /// loading of arrays is forwarded to the implementation archive
0044     template<class T>
0045     void load_array(serialization::array_wrapper<T> & x, unsigned int file_version )
0046     {
0047       implementation_archive.load_array(x,file_version);
0048     }
0049 
0050     typedef typename ImplementationArchive::use_array_optimization use_array_optimization;    
0051 
0052 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0053     friend class archive::load_access;
0054 protected:
0055 #else
0056 public:
0057 #endif
0058 
0059     ///  loading of primitives is forwarded to the implementation archive
0060     template<class T>
0061     void load(T & t)
0062     {
0063       implementation_archive >> t;
0064     }
0065 
0066 private:
0067     implementation_archive_type& implementation_archive;
0068 };
0069 
0070 } } } // end namespace boost::mpi::detail
0071 
0072 #endif // BOOST_MPI_DETAIL_FORWARD_IPRIMITIVE_HPP