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