File indexing completed on 2025-01-18 09:50:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP
0010 #define BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP
0011
0012 #include <boost/property_map/property_map.hpp>
0013
0014 namespace boost {
0015
0016
0017 template<typename Key, typename Value>
0018 inline void local_put(dummy_property_map, const Key&, const Value&) {}
0019
0020 namespace parallel {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 template<typename PropertyMap>
0031 class caching_property_map
0032 {
0033 public:
0034 typedef typename property_traits<PropertyMap>::key_type key_type;
0035 typedef typename property_traits<PropertyMap>::value_type value_type;
0036 typedef typename property_traits<PropertyMap>::reference reference;
0037 typedef typename property_traits<PropertyMap>::category category;
0038
0039 explicit caching_property_map(const PropertyMap& property_map)
0040 : property_map(property_map) {}
0041
0042 PropertyMap& base() { return property_map; }
0043 const PropertyMap& base() const { return property_map; }
0044
0045 template<typename Reduce>
0046 void set_reduce(const Reduce& reduce)
0047 { property_map.set_reduce(reduce); }
0048
0049 void reset() { property_map.reset(); }
0050
0051 #if 0
0052 reference operator[](const key_type& key) const
0053 {
0054 return property_map[key];
0055 }
0056 #endif
0057
0058 private:
0059 PropertyMap property_map;
0060 };
0061
0062 template<typename PropertyMap, typename Key>
0063 inline typename caching_property_map<PropertyMap>::value_type
0064 get(const caching_property_map<PropertyMap>& pm, const Key& key)
0065 { return get(pm.base(), key); }
0066
0067 template<typename PropertyMap, typename Key, typename Value>
0068 inline void
0069 local_put(const caching_property_map<PropertyMap>& pm, const Key& key,
0070 const Value& value)
0071 { local_put(pm.base(), key, value); }
0072
0073 template<typename PropertyMap, typename Key, typename Value>
0074 inline void
0075 cache(const caching_property_map<PropertyMap>& pm, const Key& key,
0076 const Value& value)
0077 { cache(pm.base(), key, value); }
0078
0079 template<typename PropertyMap, typename Key, typename Value>
0080 inline void
0081 put(const caching_property_map<PropertyMap>& pm, const Key& key,
0082 const Value& value)
0083 { local_put(pm.base(), key, value); }
0084
0085 template<typename PropertyMap>
0086 inline caching_property_map<PropertyMap>
0087 make_caching_property_map(const PropertyMap& pm)
0088 { return caching_property_map<PropertyMap>(pm); }
0089
0090 } }
0091
0092 #endif