fix doc example typo
[boost.git] / boost / property_map / property_map.hpp
blob0375f76c46c7a6587ccf17c1f410840a90b8f909
1 // (C) Copyright Jeremy Siek 1999-2001.
2 // Copyright (C) 2006 Trustees of Indiana University
3 // Authors: Douglas Gregor and Jeremy Siek
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // See http://www.boost.org/libs/property_map for documentation.
11 #ifndef BOOST_PROPERTY_MAP_HPP
12 #define BOOST_PROPERTY_MAP_HPP
14 #include <cassert>
15 #include <boost/config.hpp>
16 #include <boost/pending/cstddef.hpp>
17 #include <boost/detail/iterator.hpp>
18 #include <boost/concept_check.hpp>
19 #include <boost/concept_archetype.hpp>
20 #include <boost/mpl/assert.hpp>
21 #include <boost/mpl/or.hpp>
22 #include <boost/type_traits/is_same.hpp>
24 namespace boost {
26 //=========================================================================
27 // property_traits class
29 template <typename PA>
30 struct property_traits {
31 typedef typename PA::key_type key_type;
32 typedef typename PA::value_type value_type;
33 typedef typename PA::reference reference;
34 typedef typename PA::category category;
37 //=========================================================================
38 // property_traits category tags
40 namespace detail {
41 enum ePropertyMapID { READABLE_PA, WRITABLE_PA,
42 READ_WRITE_PA, LVALUE_PA, OP_BRACKET_PA,
43 RAND_ACCESS_ITER_PA, LAST_PA };
45 struct readable_property_map_tag { enum { id = detail::READABLE_PA }; };
46 struct writable_property_map_tag { enum { id = detail::WRITABLE_PA }; };
47 struct read_write_property_map_tag :
48 public readable_property_map_tag,
49 public writable_property_map_tag
50 { enum { id = detail::READ_WRITE_PA }; };
52 struct lvalue_property_map_tag : public read_write_property_map_tag
53 { enum { id = detail::LVALUE_PA }; };
55 //=========================================================================
56 // property_traits specialization for pointers
58 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
59 // The user will just have to create their own specializations for
60 // other pointers types if the compiler does not have partial
61 // specializations. Sorry!
62 #define BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(TYPE) \
63 template <> \
64 struct property_traits<TYPE*> { \
65 typedef TYPE value_type; \
66 typedef value_type& reference; \
67 typedef std::ptrdiff_t key_type; \
68 typedef lvalue_property_map_tag category; \
69 }; \
70 template <> \
71 struct property_traits<const TYPE*> { \
72 typedef TYPE value_type; \
73 typedef const value_type& reference; \
74 typedef std::ptrdiff_t key_type; \
75 typedef lvalue_property_map_tag category; \
78 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(long);
79 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(unsigned long);
80 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(int);
81 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(unsigned int);
82 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(short);
83 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(unsigned short);
84 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(char);
85 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(unsigned char);
86 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(signed char);
87 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(bool);
88 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(float);
89 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(double);
90 BOOST_SPECIALIZE_PROPERTY_TRAITS_PTR(long double);
92 // This may need to be turned off for some older compilers that don't have
93 // wchar_t intrinsically.
94 # ifndef BOOST_NO_INTRINSIC_WCHAR_T
95 template <>
96 struct property_traits<wchar_t*> {
97 typedef wchar_t value_type;
98 typedef value_type& reference;
99 typedef std::ptrdiff_t key_type;
100 typedef lvalue_property_map_tag category;
102 template <>
103 struct property_traits<const wchar_t*> {
104 typedef wchar_t value_type;
105 typedef const value_type& reference;
106 typedef std::ptrdiff_t key_type;
107 typedef lvalue_property_map_tag category;
109 # endif
111 #else
112 template <class T>
113 struct property_traits<T*> {
114 typedef T value_type;
115 typedef value_type& reference;
116 typedef std::ptrdiff_t key_type;
117 typedef lvalue_property_map_tag category;
119 template <class T>
120 struct property_traits<const T*> {
121 typedef T value_type;
122 typedef const value_type& reference;
123 typedef std::ptrdiff_t key_type;
124 typedef lvalue_property_map_tag category;
126 #endif
128 #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
129 // MSVC doesn't have Koenig lookup, so the user has to
130 // do boost::get() anyways, and the using clause
131 // doesn't really work for MSVC.
132 } // namespace boost
133 #endif
135 // These need to go in global namespace because Koenig
136 // lookup does not apply to T*.
138 // V must be convertible to T
139 template <class T, class V>
140 inline void put(T* pa, std::ptrdiff_t k, const V& val) { pa[k] = val; }
142 template <class T>
143 inline const T& get(const T* pa, std::ptrdiff_t k) { return pa[k]; }
145 #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
146 namespace boost {
147 using ::put;
148 using ::get;
149 #endif
151 //=========================================================================
152 // concept checks for property maps
154 template <class PMap, class Key>
155 struct ReadablePropertyMapConcept
157 typedef typename property_traits<PMap>::key_type key_type;
158 typedef typename property_traits<PMap>::reference reference;
159 typedef typename property_traits<PMap>::category Category;
160 typedef boost::readable_property_map_tag ReadableTag;
161 void constraints() {
162 function_requires< ConvertibleConcept<Category, ReadableTag> >();
164 val = get(pmap, k);
166 PMap pmap;
167 Key k;
168 typename property_traits<PMap>::value_type val;
170 template <typename KeyArchetype, typename ValueArchetype>
171 struct readable_property_map_archetype {
172 typedef KeyArchetype key_type;
173 typedef ValueArchetype value_type;
174 typedef convertible_to_archetype<ValueArchetype> reference;
175 typedef readable_property_map_tag category;
177 template <typename K, typename V>
178 const typename readable_property_map_archetype<K,V>::reference&
179 get(const readable_property_map_archetype<K,V>&,
180 const typename readable_property_map_archetype<K,V>::key_type&)
182 typedef typename readable_property_map_archetype<K,V>::reference R;
183 return static_object<R>::get();
187 template <class PMap, class Key>
188 struct WritablePropertyMapConcept
190 typedef typename property_traits<PMap>::key_type key_type;
191 typedef typename property_traits<PMap>::category Category;
192 typedef boost::writable_property_map_tag WritableTag;
193 void constraints() {
194 function_requires< ConvertibleConcept<Category, WritableTag> >();
195 put(pmap, k, val);
197 PMap pmap;
198 Key k;
199 typename property_traits<PMap>::value_type val;
201 template <typename KeyArchetype, typename ValueArchetype>
202 struct writable_property_map_archetype {
203 typedef KeyArchetype key_type;
204 typedef ValueArchetype value_type;
205 typedef void reference;
206 typedef writable_property_map_tag category;
208 template <typename K, typename V>
209 void put(const writable_property_map_archetype<K,V>&,
210 const typename writable_property_map_archetype<K,V>::key_type&,
211 const typename writable_property_map_archetype<K,V>::value_type&) { }
214 template <class PMap, class Key>
215 struct ReadWritePropertyMapConcept
217 typedef typename property_traits<PMap>::category Category;
218 typedef boost::read_write_property_map_tag ReadWriteTag;
219 void constraints() {
220 function_requires< ReadablePropertyMapConcept<PMap, Key> >();
221 function_requires< WritablePropertyMapConcept<PMap, Key> >();
222 function_requires< ConvertibleConcept<Category, ReadWriteTag> >();
225 template <typename KeyArchetype, typename ValueArchetype>
226 struct read_write_property_map_archetype
227 : public readable_property_map_archetype<KeyArchetype, ValueArchetype>,
228 public writable_property_map_archetype<KeyArchetype, ValueArchetype>
230 typedef KeyArchetype key_type;
231 typedef ValueArchetype value_type;
232 typedef convertible_to_archetype<ValueArchetype> reference;
233 typedef read_write_property_map_tag category;
237 template <class PMap, class Key>
238 struct LvaluePropertyMapConcept
240 typedef typename property_traits<PMap>::category Category;
241 typedef boost::lvalue_property_map_tag LvalueTag;
242 typedef typename property_traits<PMap>::reference reference;
244 void constraints() {
245 function_requires< ReadablePropertyMapConcept<PMap, Key> >();
246 function_requires< ConvertibleConcept<Category, LvalueTag> >();
248 typedef typename property_traits<PMap>::value_type value_type;
249 BOOST_MPL_ASSERT((boost::mpl::or_<
250 boost::is_same<const value_type&, reference>,
251 boost::is_same<value_type&, reference> >));
253 reference ref = pmap[k];
254 ignore_unused_variable_warning(ref);
256 PMap pmap;
257 Key k;
259 template <typename KeyArchetype, typename ValueArchetype>
260 struct lvalue_property_map_archetype
261 : public readable_property_map_archetype<KeyArchetype, ValueArchetype>
263 typedef KeyArchetype key_type;
264 typedef ValueArchetype value_type;
265 typedef const ValueArchetype& reference;
266 typedef lvalue_property_map_tag category;
267 const value_type& operator[](const key_type&) const {
268 return static_object<value_type>::get();
272 template <class PMap, class Key>
273 struct Mutable_LvaluePropertyMapConcept
275 typedef typename property_traits<PMap>::category Category;
276 typedef boost::lvalue_property_map_tag LvalueTag;
277 typedef typename property_traits<PMap>::reference reference;
278 void constraints() {
279 boost::function_requires< ReadWritePropertyMapConcept<PMap, Key> >();
280 boost::function_requires<ConvertibleConcept<Category, LvalueTag> >();
282 typedef typename property_traits<PMap>::value_type value_type;
283 BOOST_MPL_ASSERT((boost::is_same<value_type&, reference>));
285 reference ref = pmap[k];
286 ignore_unused_variable_warning(ref);
288 PMap pmap;
289 Key k;
291 template <typename KeyArchetype, typename ValueArchetype>
292 struct mutable_lvalue_property_map_archetype
293 : public readable_property_map_archetype<KeyArchetype, ValueArchetype>,
294 public writable_property_map_archetype<KeyArchetype, ValueArchetype>
296 typedef KeyArchetype key_type;
297 typedef ValueArchetype value_type;
298 typedef ValueArchetype& reference;
299 typedef lvalue_property_map_tag category;
300 value_type& operator[](const key_type&) const {
301 return static_object<value_type>::get();
305 struct identity_property_map;
307 // A helper class for constructing a property map
308 // from a class that implements operator[]
310 template <class Reference, class LvaluePropertyMap>
311 struct put_get_helper { };
313 template <class PropertyMap, class Reference, class K>
314 inline Reference
315 get(const put_get_helper<Reference, PropertyMap>& pa, const K& k)
317 Reference v = static_cast<const PropertyMap&>(pa)[k];
318 return v;
320 template <class PropertyMap, class Reference, class K, class V>
321 inline void
322 put(const put_get_helper<Reference, PropertyMap>& pa, K k, const V& v)
324 static_cast<const PropertyMap&>(pa)[k] = v;
327 //=========================================================================
328 // Adapter to turn a RandomAccessIterator into a property map
330 template <class RandomAccessIterator,
331 class IndexMap
332 #ifdef BOOST_NO_STD_ITERATOR_TRAITS
333 , class T, class R
334 #else
335 , class T = typename std::iterator_traits<RandomAccessIterator>::value_type
336 , class R = typename std::iterator_traits<RandomAccessIterator>::reference
337 #endif
339 class iterator_property_map
340 : public boost::put_get_helper< R,
341 iterator_property_map<RandomAccessIterator, IndexMap,
342 T, R> >
344 public:
345 typedef typename property_traits<IndexMap>::key_type key_type;
346 typedef T value_type;
347 typedef R reference;
348 typedef boost::lvalue_property_map_tag category;
350 inline iterator_property_map(
351 RandomAccessIterator cc = RandomAccessIterator(),
352 const IndexMap& _id = IndexMap() )
353 : iter(cc), index(_id) { }
354 inline R operator[](key_type v) const { return *(iter + get(index, v)) ; }
355 protected:
356 RandomAccessIterator iter;
357 IndexMap index;
360 #if !defined BOOST_NO_STD_ITERATOR_TRAITS
361 template <class RAIter, class ID>
362 inline iterator_property_map<
363 RAIter, ID,
364 typename std::iterator_traits<RAIter>::value_type,
365 typename std::iterator_traits<RAIter>::reference>
366 make_iterator_property_map(RAIter iter, ID id) {
367 function_requires< RandomAccessIteratorConcept<RAIter> >();
368 typedef iterator_property_map<
369 RAIter, ID,
370 typename std::iterator_traits<RAIter>::value_type,
371 typename std::iterator_traits<RAIter>::reference> PA;
372 return PA(iter, id);
374 #endif
375 template <class RAIter, class Value, class ID>
376 inline iterator_property_map<RAIter, ID, Value, Value&>
377 make_iterator_property_map(RAIter iter, ID id, Value) {
378 function_requires< RandomAccessIteratorConcept<RAIter> >();
379 typedef iterator_property_map<RAIter, ID, Value, Value&> PMap;
380 return PMap(iter, id);
383 template <class RandomAccessIterator,
384 class IndexMap
385 #ifdef BOOST_NO_STD_ITERATOR_TRAITS
386 , class T, class R
387 #else
388 , class T = typename std::iterator_traits<RandomAccessIterator>::value_type
389 , class R = typename std::iterator_traits<RandomAccessIterator>::reference
390 #endif
392 class safe_iterator_property_map
393 : public boost::put_get_helper< R,
394 safe_iterator_property_map<RandomAccessIterator, IndexMap,
395 T, R> >
397 public:
398 typedef typename property_traits<IndexMap>::key_type key_type;
399 typedef T value_type;
400 typedef R reference;
401 typedef boost::lvalue_property_map_tag category;
403 inline safe_iterator_property_map(
404 RandomAccessIterator first,
405 std::size_t n_ = 0,
406 const IndexMap& _id = IndexMap() )
407 : iter(first), n(n_), index(_id) { }
408 inline safe_iterator_property_map() { }
409 inline R operator[](key_type v) const {
410 assert(get(index, v) < n);
411 return *(iter + get(index, v)) ;
413 typename property_traits<IndexMap>::value_type size() const { return n; }
414 protected:
415 RandomAccessIterator iter;
416 typename property_traits<IndexMap>::value_type n;
417 IndexMap index;
420 #if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
421 template <class RAIter, class ID>
422 inline safe_iterator_property_map<
423 RAIter, ID,
424 typename boost::detail::iterator_traits<RAIter>::value_type,
425 typename boost::detail::iterator_traits<RAIter>::reference>
426 make_safe_iterator_property_map(RAIter iter, std::size_t n, ID id) {
427 function_requires< RandomAccessIteratorConcept<RAIter> >();
428 typedef safe_iterator_property_map<
429 RAIter, ID,
430 typename boost::detail::iterator_traits<RAIter>::value_type,
431 typename boost::detail::iterator_traits<RAIter>::reference> PA;
432 return PA(iter, n, id);
434 #endif
435 template <class RAIter, class Value, class ID>
436 inline safe_iterator_property_map<RAIter, ID, Value, Value&>
437 make_safe_iterator_property_map(RAIter iter, std::size_t n, ID id, Value) {
438 function_requires< RandomAccessIteratorConcept<RAIter> >();
439 typedef safe_iterator_property_map<RAIter, ID, Value, Value&> PMap;
440 return PMap(iter, n, id);
443 //=========================================================================
444 // An adaptor to turn a Unique Pair Associative Container like std::map or
445 // std::hash_map into an Lvalue Property Map.
447 template <typename UniquePairAssociativeContainer>
448 class associative_property_map
449 : public boost::put_get_helper<
450 typename UniquePairAssociativeContainer::value_type::second_type&,
451 associative_property_map<UniquePairAssociativeContainer> >
453 typedef UniquePairAssociativeContainer C;
454 public:
455 typedef typename C::key_type key_type;
456 typedef typename C::value_type::second_type value_type;
457 typedef value_type& reference;
458 typedef lvalue_property_map_tag category;
459 associative_property_map() : m_c(0) { }
460 associative_property_map(C& c) : m_c(&c) { }
461 reference operator[](const key_type& k) const {
462 return (*m_c)[k];
464 private:
465 C* m_c;
468 template <class UniquePairAssociativeContainer>
469 associative_property_map<UniquePairAssociativeContainer>
470 make_assoc_property_map(UniquePairAssociativeContainer& c)
472 return associative_property_map<UniquePairAssociativeContainer>(c);
475 template <typename UniquePairAssociativeContainer>
476 class const_associative_property_map
477 : public boost::put_get_helper<
478 const typename UniquePairAssociativeContainer::value_type::second_type&,
479 const_associative_property_map<UniquePairAssociativeContainer> >
481 typedef UniquePairAssociativeContainer C;
482 public:
483 typedef typename C::key_type key_type;
484 typedef typename C::value_type::second_type value_type;
485 typedef const value_type& reference;
486 typedef lvalue_property_map_tag category;
487 const_associative_property_map() : m_c(0) { }
488 const_associative_property_map(const C& c) : m_c(&c) { }
489 reference operator[](const key_type& k) const {
490 return m_c->find(k)->second;
492 private:
493 C const* m_c;
496 template <class UniquePairAssociativeContainer>
497 const_associative_property_map<UniquePairAssociativeContainer>
498 make_assoc_property_map(const UniquePairAssociativeContainer& c)
500 return const_associative_property_map<UniquePairAssociativeContainer>(c);
503 //=========================================================================
504 // A property map that always returns the same object by value.
506 template <typename ValueType>
507 class static_property_map :
508 public
509 boost::put_get_helper<ValueType,static_property_map<ValueType> >
511 ValueType value;
512 public:
513 typedef void key_type;
514 typedef ValueType value_type;
515 typedef ValueType reference;
516 typedef readable_property_map_tag category;
517 static_property_map(ValueType v) : value(v) {}
519 template<typename T>
520 inline reference operator[](T) const { return value; }
523 //=========================================================================
524 // A property map that always returns a reference to the same object.
526 template <typename KeyType, typename ValueType>
527 class ref_property_map :
528 public
529 boost::put_get_helper<ValueType&,ref_property_map<KeyType,ValueType> >
531 ValueType* value;
532 public:
533 typedef KeyType key_type;
534 typedef ValueType value_type;
535 typedef ValueType& reference;
536 typedef lvalue_property_map_tag category;
537 ref_property_map(ValueType& v) : value(&v) {}
538 ValueType& operator[](key_type const&) const { return *value; }
541 //=========================================================================
542 // A property map that applies the identity function to integers
543 struct identity_property_map
544 : public boost::put_get_helper<std::size_t,
545 identity_property_map>
547 typedef std::size_t key_type;
548 typedef std::size_t value_type;
549 typedef std::size_t reference;
550 typedef boost::readable_property_map_tag category;
552 inline value_type operator[](const key_type& v) const { return v; }
555 //=========================================================================
556 // A property map that does not do anything, for
557 // when you have to supply a property map, but don't need it.
558 namespace detail {
559 struct dummy_pmap_reference {
560 template <class T>
561 dummy_pmap_reference& operator=(const T&) { return *this; }
562 operator int() { return 0; }
565 class dummy_property_map
566 : public boost::put_get_helper<detail::dummy_pmap_reference,
567 dummy_property_map >
569 public:
570 typedef void key_type;
571 typedef int value_type;
572 typedef detail::dummy_pmap_reference reference;
573 typedef boost::read_write_property_map_tag category;
574 inline dummy_property_map() : c(0) { }
575 inline dummy_property_map(value_type cc) : c(cc) { }
576 inline dummy_property_map(const dummy_property_map& x)
577 : c(x.c) { }
578 template <class Vertex>
579 inline reference operator[](Vertex) const { return reference(); }
580 protected:
581 value_type c;
585 } // namespace boost
587 #ifdef BOOST_GRAPH_USE_MPI
588 #include <boost/property_map/parallel/distributed_property_map.hpp>
589 #include <boost/property_map/parallel/local_property_map.hpp>
591 namespace boost {
592 /** Distributed iterator property map.
594 * This specialization of @ref iterator_property_map builds a
595 * distributed iterator property map given the local index maps
596 * generated by distributed graph types that automatically have index
597 * properties.
599 * This specialization is useful when creating external distributed
600 * property maps via the same syntax used to create external
601 * sequential property maps.
603 template<typename RandomAccessIterator, typename ProcessGroup,
604 typename GlobalMap, typename StorageMap,
605 typename ValueType, typename Reference>
606 class iterator_property_map
607 <RandomAccessIterator,
608 local_property_map<ProcessGroup, GlobalMap, StorageMap>,
609 ValueType, Reference>
610 : public parallel::distributed_property_map
611 <ProcessGroup,
612 GlobalMap,
613 iterator_property_map<RandomAccessIterator, StorageMap,
614 ValueType, Reference> >
616 typedef iterator_property_map<RandomAccessIterator, StorageMap,
617 ValueType, Reference> local_iterator_map;
619 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
620 local_iterator_map> inherited;
622 typedef local_property_map<ProcessGroup, GlobalMap, StorageMap>
623 index_map_type;
624 typedef iterator_property_map self_type;
626 public:
627 iterator_property_map() { }
629 iterator_property_map(RandomAccessIterator cc, const index_map_type& id)
630 : inherited(id.process_group(), id.global(),
631 local_iterator_map(cc, id.base())) { }
634 /** Distributed iterator property map.
636 * This specialization of @ref iterator_property_map builds a
637 * distributed iterator property map given a distributed index
638 * map. Only the local portion of the distributed index property map
639 * is utilized.
641 * This specialization is useful when creating external distributed
642 * property maps via the same syntax used to create external
643 * sequential property maps.
645 template<typename RandomAccessIterator, typename ProcessGroup,
646 typename GlobalMap, typename StorageMap,
647 typename ValueType, typename Reference>
648 class iterator_property_map<
649 RandomAccessIterator,
650 parallel::distributed_property_map<ProcessGroup,GlobalMap,StorageMap>,
651 ValueType, Reference
653 : public parallel::distributed_property_map
654 <ProcessGroup,
655 GlobalMap,
656 iterator_property_map<RandomAccessIterator, StorageMap,
657 ValueType, Reference> >
659 typedef iterator_property_map<RandomAccessIterator, StorageMap,
660 ValueType, Reference> local_iterator_map;
662 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
663 local_iterator_map> inherited;
665 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
666 StorageMap>
667 index_map_type;
669 public:
670 iterator_property_map() { }
672 iterator_property_map(RandomAccessIterator cc, const index_map_type& id)
673 : inherited(id.process_group(), id.global(),
674 local_iterator_map(cc, id.base())) { }
677 namespace parallel {
678 // Generate an iterator property map with a specific kind of ghost
679 // cells
680 template<typename RandomAccessIterator, typename ProcessGroup,
681 typename GlobalMap, typename StorageMap>
682 distributed_property_map<ProcessGroup,
683 GlobalMap,
684 iterator_property_map<RandomAccessIterator,
685 StorageMap> >
686 make_iterator_property_map(RandomAccessIterator cc,
687 local_property_map<ProcessGroup, GlobalMap,
688 StorageMap> index_map)
690 typedef distributed_property_map<
691 ProcessGroup, GlobalMap,
692 iterator_property_map<RandomAccessIterator, StorageMap> >
693 result_type;
694 return result_type(index_map.process_group(), index_map.global(),
695 make_iterator_property_map(cc, index_map.base()));
698 } // end namespace parallel
700 /** Distributed safe iterator property map.
702 * This specialization of @ref safe_iterator_property_map builds a
703 * distributed iterator property map given the local index maps
704 * generated by distributed graph types that automatically have index
705 * properties.
707 * This specialization is useful when creating external distributed
708 * property maps via the same syntax used to create external
709 * sequential property maps.
711 template<typename RandomAccessIterator, typename ProcessGroup,
712 typename GlobalMap, typename StorageMap, typename ValueType,
713 typename Reference>
714 class safe_iterator_property_map
715 <RandomAccessIterator,
716 local_property_map<ProcessGroup, GlobalMap, StorageMap>,
717 ValueType, Reference>
718 : public parallel::distributed_property_map
719 <ProcessGroup,
720 GlobalMap,
721 safe_iterator_property_map<RandomAccessIterator, StorageMap,
722 ValueType, Reference> >
724 typedef safe_iterator_property_map<RandomAccessIterator, StorageMap,
725 ValueType, Reference> local_iterator_map;
727 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
728 local_iterator_map> inherited;
730 typedef local_property_map<ProcessGroup, GlobalMap, StorageMap> index_map_type;
732 public:
733 safe_iterator_property_map() { }
735 safe_iterator_property_map(RandomAccessIterator cc, std::size_t n,
736 const index_map_type& id)
737 : inherited(id.process_group(), id.global(),
738 local_iterator_map(cc, n, id.base())) { }
741 /** Distributed safe iterator property map.
743 * This specialization of @ref safe_iterator_property_map builds a
744 * distributed iterator property map given a distributed index
745 * map. Only the local portion of the distributed index property map
746 * is utilized.
748 * This specialization is useful when creating external distributed
749 * property maps via the same syntax used to create external
750 * sequential property maps.
752 template<typename RandomAccessIterator, typename ProcessGroup,
753 typename GlobalMap, typename StorageMap,
754 typename ValueType, typename Reference>
755 class safe_iterator_property_map<
756 RandomAccessIterator,
757 parallel::distributed_property_map<ProcessGroup,GlobalMap,StorageMap>,
758 ValueType, Reference>
759 : public parallel::distributed_property_map
760 <ProcessGroup,
761 GlobalMap,
762 safe_iterator_property_map<RandomAccessIterator, StorageMap,
763 ValueType, Reference> >
765 typedef safe_iterator_property_map<RandomAccessIterator, StorageMap,
766 ValueType, Reference> local_iterator_map;
768 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
769 local_iterator_map> inherited;
771 typedef parallel::distributed_property_map<ProcessGroup, GlobalMap,
772 StorageMap>
773 index_map_type;
775 public:
776 safe_iterator_property_map() { }
778 safe_iterator_property_map(RandomAccessIterator cc, std::size_t n,
779 const index_map_type& id)
780 : inherited(id.process_group(), id.global(),
781 local_iterator_map(cc, n, id.base())) { }
785 #endif // BOOST_GRAPH_USE_MPI
787 #include <boost/property_map/vector_property_map.hpp>
789 #endif /* BOOST_PROPERTY_MAP_HPP */