Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:20

0001 // Copyright (C) 2007 Douglas Gregor and 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 //
0006 // This file contains helper data structures for use in transmitting
0007 // properties. The basic idea is to optimize away any storage for the
0008 // properties when no properties are specified.
0009 #ifndef BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP
0010 #define BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP
0011 
0012 #ifndef BOOST_GRAPH_USE_MPI
0013 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
0014 #endif
0015 
0016 #include <boost/mpi/datatype.hpp>
0017 #include <boost/property_map/property_map.hpp>
0018 #include <boost/property_map/parallel/parallel_property_maps.hpp>
0019 #include <boost/serialization/base_object.hpp>
0020 #include <boost/mpl/and.hpp>
0021 #include <boost/graph/parallel/detail/untracked_pair.hpp>
0022 
0023 namespace boost { namespace detail { namespace parallel {
0024 
0025 /**
0026  * This structure contains an instance of @c Property, unless @c
0027  * Property is a placeholder for "no property". Always access the
0028  * property through @c get_property. Typically used as a base class.
0029  */
0030 template<typename Property>
0031 struct maybe_store_property
0032 {
0033   maybe_store_property() {}
0034   maybe_store_property(const Property& p) : p(p) {}
0035 
0036   Property&       get_property()       { return p; }
0037   const Property& get_property() const { return p; }
0038 
0039 private:
0040   Property p;
0041 
0042   friend class boost::serialization::access;
0043 
0044   template<typename Archiver>
0045   void serialize(Archiver& ar, const unsigned int /*version*/)
0046   {
0047     ar & p;
0048   }
0049 };
0050 
0051 template<>
0052 struct maybe_store_property<no_property>
0053 {
0054   maybe_store_property() {}
0055   maybe_store_property(no_property) {}
0056 
0057   no_property get_property() const { return no_property(); }
0058 
0059 private:
0060   friend class boost::serialization::access;
0061 
0062   template<typename Archiver>
0063   void serialize(Archiver&, const unsigned int /*version*/) { }
0064 };
0065 
0066 /**
0067  * This structure is a simple pair that also contains a property.
0068  */
0069 template<typename T, typename U, typename Property>
0070 class pair_with_property
0071   : public boost::parallel::detail::untracked_pair<T, U>
0072   , public maybe_store_property<Property>
0073 {
0074 public:
0075   typedef boost::parallel::detail::untracked_pair<T, U>           pair_base;
0076   typedef maybe_store_property<Property> property_base;
0077 
0078   pair_with_property() { }
0079 
0080   pair_with_property(const T& t, const U& u, const Property& property)
0081     : pair_base(t, u), property_base(property) { }
0082 
0083 private:
0084   friend class boost::serialization::access;
0085 
0086   template<typename Archiver>
0087   void serialize(Archiver& ar, const unsigned int /*version*/) 
0088   { 
0089     ar & boost::serialization::base_object<pair_base>(*this)
0090        & boost::serialization::base_object<property_base>(*this);
0091   }
0092 };
0093 
0094 template<typename T, typename U, typename Property>
0095 inline pair_with_property<T, U, Property>
0096 make_pair_with_property(const T& t, const U& u, const Property& property)
0097 {
0098   return pair_with_property<T, U, Property>(t, u, property);
0099 }
0100 
0101 } } } // end namespace boost::parallel::detail
0102 
0103 namespace boost { namespace mpi {
0104 
0105 template<> 
0106 struct is_mpi_datatype<boost::detail::parallel::maybe_store_property<no_property> > : mpl::true_ { };
0107 
0108 template<typename Property>
0109 struct is_mpi_datatype<boost::detail::parallel::maybe_store_property<Property> >
0110   : is_mpi_datatype<Property> { };
0111 
0112 template<typename T, typename U, typename Property>
0113 struct is_mpi_datatype<boost::detail::parallel::pair_with_property<T, U, Property> >
0114   : boost::mpl::and_<is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> >,
0115                      is_mpi_datatype<Property> > { };
0116 
0117 } } // end namespace boost::mpi
0118 
0119 BOOST_IS_BITWISE_SERIALIZABLE(boost::detail::parallel::maybe_store_property<no_property>)
0120 
0121 namespace boost { namespace serialization {
0122 
0123 template<typename Property>
0124 struct is_bitwise_serializable<boost::detail::parallel::maybe_store_property<Property> >
0125   : is_bitwise_serializable<Property> { };
0126 
0127 template<typename Property>
0128 struct implementation_level<boost::detail::parallel::maybe_store_property<Property> >
0129  : mpl::int_<object_serializable> {} ;
0130 
0131 template<typename Property>
0132 struct tracking_level<boost::detail::parallel::maybe_store_property<Property> >
0133  : mpl::int_<track_never> {} ;
0134 
0135 template<typename T, typename U, typename Property>
0136 struct is_bitwise_serializable<
0137         boost::detail::parallel::pair_with_property<T, U, Property> >
0138   : boost::mpl::and_<is_bitwise_serializable<boost::parallel::detail::untracked_pair<T, U> >,
0139                      is_bitwise_serializable<Property> > { };
0140 
0141 template<typename T, typename U, typename Property>
0142 struct implementation_level<
0143         boost::detail::parallel::pair_with_property<T, U, Property> >
0144  : mpl::int_<object_serializable> {} ;
0145 
0146 template<typename T, typename U, typename Property>
0147 struct tracking_level<
0148         boost::detail::parallel::pair_with_property<T, U, Property> >
0149  : mpl::int_<track_never> {} ;
0150 
0151 } } // end namespace boost::serialization
0152 
0153 #endif // BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP