]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/property_map/include/boost/property_map/parallel/caching_property_map.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / property_map / include / boost / property_map / parallel / caching_property_map.hpp
1 // Copyright 2004 The Trustees of Indiana University.
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 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Authors: Douglas Gregor
8 // Andrew Lumsdaine
9 #ifndef BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP
10 #define BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP
11
12 #include <boost/property_map/property_map.hpp>
13
14 namespace boost {
15
16 // This probably doesn't belong here
17 template<typename Key, typename Value>
18 inline void local_put(dummy_property_map, const Key&, const Value&) {}
19
20 namespace parallel {
21
22 /** Property map that caches values placed in it but does not
23 * broadcast values to remote processors. This class template is
24 * meant as an adaptor for @ref distributed_property_map that
25 * suppresses communication in the event of a remote @c put operation
26 * by mapping it to a local @c put operation.
27 *
28 * @todo Find a better name for @ref caching_property_map
29 */
30 template<typename PropertyMap>
31 class caching_property_map
32 {
33 public:
34 typedef typename property_traits<PropertyMap>::key_type key_type;
35 typedef typename property_traits<PropertyMap>::value_type value_type;
36 typedef typename property_traits<PropertyMap>::reference reference;
37 typedef typename property_traits<PropertyMap>::category category;
38
39 explicit caching_property_map(const PropertyMap& property_map)
40 : property_map(property_map) {}
41
42 PropertyMap& base() { return property_map; }
43 const PropertyMap& base() const { return property_map; }
44
45 template<typename Reduce>
46 void set_reduce(const Reduce& reduce)
47 { property_map.set_reduce(reduce); }
48
49 void reset() { property_map.reset(); }
50
51 #if 0
52 reference operator[](const key_type& key) const
53 {
54 return property_map[key];
55 }
56 #endif
57
58 private:
59 PropertyMap property_map;
60 };
61
62 template<typename PropertyMap, typename Key>
63 inline typename caching_property_map<PropertyMap>::value_type
64 get(const caching_property_map<PropertyMap>& pm, const Key& key)
65 { return get(pm.base(), key); }
66
67 template<typename PropertyMap, typename Key, typename Value>
68 inline void
69 local_put(const caching_property_map<PropertyMap>& pm, const Key& key,
70 const Value& value)
71 { local_put(pm.base(), key, value); }
72
73 template<typename PropertyMap, typename Key, typename Value>
74 inline void
75 cache(const caching_property_map<PropertyMap>& pm, const Key& key,
76 const Value& value)
77 { cache(pm.base(), key, value); }
78
79 template<typename PropertyMap, typename Key, typename Value>
80 inline void
81 put(const caching_property_map<PropertyMap>& pm, const Key& key,
82 const Value& value)
83 { local_put(pm.base(), key, value); }
84
85 template<typename PropertyMap>
86 inline caching_property_map<PropertyMap>
87 make_caching_property_map(const PropertyMap& pm)
88 { return caching_property_map<PropertyMap>(pm); }
89
90 } } // end namespace boost::parallel
91
92 #endif // BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP