3#ifndef DUNE_PROPERTYMAP_HH
4#define DUNE_PROPERTYMAP_HH
14 struct PropertyMapTraits
19 typedef typename PM::KeyType KeyType;
23 typedef typename PM::ValueType ValueType;
27 typedef typename PM::Reference Reference;
31 typedef typename PM::Category Category;
58 struct PropertyMapTraits<T*>
61 typedef ValueType& Reference;
62 typedef std::ptrdiff_t KeyType;
68 struct PropertyMapTraits<const T*>
71 typedef const ValueType& Reference;
72 typedef std::ptrdiff_t KeyType;
73 typedef LvaluePropertyMapTag Category;
76 template<
class Reference,
class PropertyMap>
77 struct RAPropertyMapHelper
80 template<
class Reference,
class PropertyMap,
class Key>
82 get(
const RAPropertyMapHelper<Reference,PropertyMap>& pmap,
85 return static_cast<const PropertyMap&
>(pmap)[key];
88 template<
class Reference,
class PropertyMap,
class Key,
class Value>
90 put(
const RAPropertyMapHelper<Reference,PropertyMap>& pmap,
91 const Key& key,
const Value& value)
93 static_assert(std::is_convertible<typename PropertyMap::Category,WritablePropertyMapTag>::value,
94 "WritablePropertyMapTag required!");
95 static_cast<const PropertyMap&
>(pmap)[key] = value;
101 template<
class RAI,
class IM,
102 class T =
typename std::iterator_traits<RAI>::value_type,
103 class R =
typename std::iterator_traits<RAI>::reference>
105 :
public RAPropertyMapHelper<R,IteratorPropertyMap<RAI,IM,T,R> >
149 : iter_(iter), indexMap_(im)
154 : iter_(), indexMap_()
160 return *(iter_ + get(indexMap_, key));
176 : RAPropertyMapHelper<typename T::value_type::second_type&,
177 AssociativePropertyMap<T> >
182 typedef T UniqueAssociativeContainer;
187 typedef typename UniqueAssociativeContainer::value_type::first_type
193 typedef typename UniqueAssociativeContainer::value_type::second_type
199 typedef ValueType& Reference;
220 inline Reference operator[](KeyType key)
const
222 return map_->find(key)->second;
225 UniqueAssociativeContainer* map_;
234 : RAPropertyMapHelper<const typename T::value_type::second_type&,
235 ConstAssociativePropertyMap<T> >
240 typedef T UniqueAssociativeContainer;
245 typedef typename UniqueAssociativeContainer::value_type::first_type
251 typedef typename UniqueAssociativeContainer::value_type::second_type
257 typedef const ValueType& Reference;
278 inline Reference operator[](KeyType key)
const
280 return map_->find(key)->second;
283 const UniqueAssociativeContainer* map_;
290 :
public RAPropertyMapHelper<std::size_t, IdentityMap>
316 template<
typename T,
typename C>
An adapter to turn an unique associative container into a property map.
Definition: propertymap.hh:178
An adaptor to turn an unique associative container into a property map.
Definition: propertymap.hh:236
Adapter to turn a random access iterator into a property map.
Definition: propertymap.hh:106
IndexMap::KeyType KeyType
The key type of the property map.
Definition: propertymap.hh:123
R Reference
The reference type of the property map.
Definition: propertymap.hh:133
T ValueType
The value type of the property map.
Definition: propertymap.hh:128
Reference operator[](KeyType key) const
Access the a value by reference.
Definition: propertymap.hh:158
IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap())
Constructor.
Definition: propertymap.hh:147
IteratorPropertyMap()
Constructor.
Definition: propertymap.hh:153
IM IndexMap
The type of the index map.
Definition: propertymap.hh:118
RAI RandomAccessIterator
The type of the random access iterator.
Definition: propertymap.hh:111
LvaluePropertyMapTag Category
The category of this property map.
Definition: propertymap.hh:138
Dune namespace.
Definition: alignedallocator.hh:10
A property map that applies the identity function to integers.
Definition: propertymap.hh:291
std::size_t ValueType
The value type of the map.
Definition: propertymap.hh:296
std::size_t KeyType
The key type of the map.
Definition: propertymap.hh:293
std::size_t Reference
The reference type of the map.
Definition: propertymap.hh:299
ReadablePropertyMapTag Category
The category of the map.
Definition: propertymap.hh:302
Tag for the category of lvalue property maps.
Definition: propertymap.hh:55
Selector for the property map type.
Definition: propertymap.hh:318
T Tag
the tag identifying the property.
Definition: propertymap.hh:322
C Container
The container type to whose entries the properties are attached.
Definition: propertymap.hh:327
Tag for the category of readable and writable property maps.
Definition: propertymap.hh:48
Tag for the category of readable property maps.
Definition: propertymap.hh:36
Tag for the category of writable property maps.
Definition: propertymap.hh:40