annotate DEPENDENCIES/generic/include/boost/graph/parallel/detail/property_holders.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (C) 2007 Douglas Gregor and Matthias Troyer
Chris@16 2 //
Chris@16 3 // Use, modification and distribution is subject to the Boost Software
Chris@16 4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 //
Chris@16 6 // This file contains helper data structures for use in transmitting
Chris@16 7 // properties. The basic idea is to optimize away any storage for the
Chris@16 8 // properties when no properties are specified.
Chris@16 9 #ifndef BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP
Chris@16 10 #define BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP
Chris@16 11
Chris@16 12 #ifndef BOOST_GRAPH_USE_MPI
Chris@16 13 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
Chris@16 14 #endif
Chris@16 15
Chris@16 16 #include <boost/mpi/datatype.hpp>
Chris@16 17 #include <boost/property_map/property_map.hpp>
Chris@16 18 #include <boost/serialization/base_object.hpp>
Chris@16 19 #include <boost/mpl/and.hpp>
Chris@16 20 #include <boost/graph/parallel/detail/untracked_pair.hpp>
Chris@16 21
Chris@16 22 namespace boost { namespace detail { namespace parallel {
Chris@16 23
Chris@16 24 /**
Chris@16 25 * This structure contains an instance of @c Property, unless @c
Chris@16 26 * Property is a placeholder for "no property". Always access the
Chris@16 27 * property through @c get_property. Typically used as a base class.
Chris@16 28 */
Chris@16 29 template<typename Property>
Chris@16 30 struct maybe_store_property
Chris@16 31 {
Chris@16 32 maybe_store_property() {}
Chris@16 33 maybe_store_property(const Property& p) : p(p) {}
Chris@16 34
Chris@16 35 Property& get_property() { return p; }
Chris@16 36 const Property& get_property() const { return p; }
Chris@16 37
Chris@16 38 private:
Chris@16 39 Property p;
Chris@16 40
Chris@16 41 friend class boost::serialization::access;
Chris@16 42
Chris@16 43 template<typename Archiver>
Chris@16 44 void serialize(Archiver& ar, const unsigned int /*version*/)
Chris@16 45 {
Chris@16 46 ar & p;
Chris@16 47 }
Chris@16 48 };
Chris@16 49
Chris@16 50 template<>
Chris@16 51 struct maybe_store_property<no_property>
Chris@16 52 {
Chris@16 53 maybe_store_property() {}
Chris@16 54 maybe_store_property(no_property) {}
Chris@16 55
Chris@16 56 no_property get_property() const { return no_property(); }
Chris@16 57
Chris@16 58 private:
Chris@16 59 friend class boost::serialization::access;
Chris@16 60
Chris@16 61 template<typename Archiver>
Chris@16 62 void serialize(Archiver&, const unsigned int /*version*/) { }
Chris@16 63 };
Chris@16 64
Chris@16 65 /**
Chris@16 66 * This structure is a simple pair that also contains a property.
Chris@16 67 */
Chris@16 68 template<typename T, typename U, typename Property>
Chris@16 69 class pair_with_property
Chris@16 70 : public boost::parallel::detail::untracked_pair<T, U>
Chris@16 71 , public maybe_store_property<Property>
Chris@16 72 {
Chris@16 73 public:
Chris@16 74 typedef boost::parallel::detail::untracked_pair<T, U> pair_base;
Chris@16 75 typedef maybe_store_property<Property> property_base;
Chris@16 76
Chris@16 77 pair_with_property() { }
Chris@16 78
Chris@16 79 pair_with_property(const T& t, const U& u, const Property& property)
Chris@16 80 : pair_base(t, u), property_base(property) { }
Chris@16 81
Chris@16 82 private:
Chris@16 83 friend class boost::serialization::access;
Chris@16 84
Chris@16 85 template<typename Archiver>
Chris@16 86 void serialize(Archiver& ar, const unsigned int /*version*/)
Chris@16 87 {
Chris@16 88 ar & boost::serialization::base_object<pair_base>(*this)
Chris@16 89 & boost::serialization::base_object<property_base>(*this);
Chris@16 90 }
Chris@16 91 };
Chris@16 92
Chris@16 93 template<typename T, typename U, typename Property>
Chris@16 94 inline pair_with_property<T, U, Property>
Chris@16 95 make_pair_with_property(const T& t, const U& u, const Property& property)
Chris@16 96 {
Chris@16 97 return pair_with_property<T, U, Property>(t, u, property);
Chris@16 98 }
Chris@16 99
Chris@16 100 } } } // end namespace boost::parallel::detail
Chris@16 101
Chris@16 102 namespace boost { namespace mpi {
Chris@16 103
Chris@16 104 template<>
Chris@16 105 struct is_mpi_datatype<boost::detail::parallel::maybe_store_property<no_property> > : mpl::true_ { };
Chris@16 106
Chris@16 107 template<typename Property>
Chris@16 108 struct is_mpi_datatype<boost::detail::parallel::maybe_store_property<Property> >
Chris@16 109 : is_mpi_datatype<Property> { };
Chris@16 110
Chris@16 111 template<typename T, typename U, typename Property>
Chris@16 112 struct is_mpi_datatype<boost::detail::parallel::pair_with_property<T, U, Property> >
Chris@16 113 : boost::mpl::and_<is_mpi_datatype<boost::parallel::detail::untracked_pair<T, U> >,
Chris@16 114 is_mpi_datatype<Property> > { };
Chris@16 115
Chris@16 116 } } // end namespace boost::mpi
Chris@16 117
Chris@16 118 BOOST_IS_BITWISE_SERIALIZABLE(boost::detail::parallel::maybe_store_property<no_property>)
Chris@16 119
Chris@16 120 namespace boost { namespace serialization {
Chris@16 121
Chris@16 122 template<typename Property>
Chris@16 123 struct is_bitwise_serializable<boost::detail::parallel::maybe_store_property<Property> >
Chris@16 124 : is_bitwise_serializable<Property> { };
Chris@16 125
Chris@16 126 template<typename Property>
Chris@16 127 struct implementation_level<boost::detail::parallel::maybe_store_property<Property> >
Chris@16 128 : mpl::int_<object_serializable> {} ;
Chris@16 129
Chris@16 130 template<typename Property>
Chris@16 131 struct tracking_level<boost::detail::parallel::maybe_store_property<Property> >
Chris@16 132 : mpl::int_<track_never> {} ;
Chris@16 133
Chris@16 134 template<typename T, typename U, typename Property>
Chris@16 135 struct is_bitwise_serializable<
Chris@16 136 boost::detail::parallel::pair_with_property<T, U, Property> >
Chris@16 137 : boost::mpl::and_<is_bitwise_serializable<boost::parallel::detail::untracked_pair<T, U> >,
Chris@16 138 is_bitwise_serializable<Property> > { };
Chris@16 139
Chris@16 140 template<typename T, typename U, typename Property>
Chris@16 141 struct implementation_level<
Chris@16 142 boost::detail::parallel::pair_with_property<T, U, Property> >
Chris@16 143 : mpl::int_<object_serializable> {} ;
Chris@16 144
Chris@16 145 template<typename T, typename U, typename Property>
Chris@16 146 struct tracking_level<
Chris@16 147 boost::detail::parallel::pair_with_property<T, U, Property> >
Chris@16 148 : mpl::int_<track_never> {} ;
Chris@16 149
Chris@16 150 } } // end namespace boost::serialization
Chris@16 151
Chris@16 152 #endif // BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP