annotate DEPENDENCIES/generic/include/boost/property_map/parallel/local_property_map.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 c530137014c0
children
rev   line source
Chris@16 1 // Copyright (C) 2004-2006 The Trustees of Indiana University.
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 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 // Authors: Douglas Gregor
Chris@16 8 // Andrew Lumsdaine
Chris@16 9
Chris@16 10 // The placement of this #include probably looks very odd relative to
Chris@16 11 // the #ifndef/#define pair below. However, this placement is
Chris@16 12 // extremely important to allow the various property map headers to be
Chris@16 13 // included in any order.
Chris@16 14 #include <boost/property_map/property_map.hpp>
Chris@16 15
Chris@16 16 #ifndef BOOST_PARALLEL_LOCAL_PROPERTY_MAP_HPP
Chris@16 17 #define BOOST_PARALLEL_LOCAL_PROPERTY_MAP_HPP
Chris@16 18
Chris@16 19 #include <boost/assert.hpp>
Chris@16 20
Chris@16 21 namespace boost {
Chris@16 22 /** Property map that accesses an underlying, local property map
Chris@16 23 * using a subset of the global keys.
Chris@16 24 */
Chris@16 25 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
Chris@16 26 class local_property_map
Chris@16 27 {
Chris@16 28 typedef typename property_traits<GlobalMap>::value_type owner_local_pair;
Chris@16 29
Chris@16 30 public:
Chris@16 31 typedef ProcessGroup process_group_type;
Chris@16 32 typedef typename property_traits<StorageMap>::value_type value_type;
Chris@16 33 typedef typename property_traits<GlobalMap>::key_type key_type;
Chris@16 34 typedef typename property_traits<StorageMap>::reference reference;
Chris@16 35 typedef typename property_traits<StorageMap>::category category;
Chris@16 36
Chris@16 37 local_property_map() { }
Chris@16 38
Chris@101 39 local_property_map(const ProcessGroup& process_group,
Chris@16 40 const GlobalMap& global, const StorageMap& storage)
Chris@16 41 : process_group_(process_group), global_(global), storage(storage) { }
Chris@16 42
Chris@101 43 reference operator[](const key_type& key)
Chris@101 44 {
Chris@16 45 owner_local_pair p = get(global_, key);
Chris@16 46 BOOST_ASSERT(p.first == process_id(process_group_));
Chris@101 47 return storage[p.second];
Chris@16 48 }
Chris@16 49
Chris@16 50 GlobalMap& global() const { return global_; }
Chris@16 51 StorageMap& base() const { return storage; }
Chris@16 52
Chris@16 53 ProcessGroup& process_group() { return process_group_; }
Chris@16 54 const ProcessGroup& process_group() const { return process_group_; }
Chris@16 55
Chris@16 56 private:
Chris@16 57 ProcessGroup process_group_;
Chris@16 58 mutable GlobalMap global_;
Chris@16 59 mutable StorageMap storage;
Chris@16 60 };
Chris@16 61
Chris@16 62 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
Chris@16 63 inline
Chris@16 64 typename local_property_map<ProcessGroup, GlobalMap, StorageMap>::reference
Chris@101 65 get(const local_property_map<ProcessGroup, GlobalMap, StorageMap>& pm,
Chris@16 66 typename local_property_map<ProcessGroup, GlobalMap, StorageMap>::key_type
Chris@16 67 const & key)
Chris@16 68
Chris@16 69 {
Chris@16 70 typename property_traits<GlobalMap>::value_type p = get(pm.global(), key);
Chris@16 71 return get(pm.base(), p.second);
Chris@16 72 }
Chris@16 73
Chris@16 74 template<typename ProcessGroup, typename GlobalMap, typename StorageMap>
Chris@16 75 inline void
Chris@101 76 put(const local_property_map<ProcessGroup, GlobalMap, StorageMap>& pm,
Chris@16 77 typename local_property_map<ProcessGroup, GlobalMap, StorageMap>
Chris@16 78 ::key_type const & key,
Chris@16 79 typename local_property_map<ProcessGroup, GlobalMap, StorageMap>
Chris@16 80 ::value_type const& v)
Chris@16 81 {
Chris@16 82 typename property_traits<GlobalMap>::value_type p = get(pm.global(), key);
Chris@16 83 BOOST_ASSERT(p.first == process_id(pm.process_group()));
Chris@16 84 put(pm.base(), p.second, v);
Chris@16 85 }
Chris@16 86 } // end namespace boost
Chris@16 87 #endif // BOOST_PARALLEL_LOCAL_PROPERTY_MAP_HPP