3#ifndef DUNE_PROPERTYMAP_HH
4#define DUNE_PROPERTYMAP_HH
15 struct PropertyMapTraits
20 typedef typename PM::KeyType KeyType;
24 typedef typename PM::ValueType ValueType;
28 typedef typename PM::Reference Reference;
32 typedef typename PM::Category Category;
59 struct PropertyMapTraits<T*>
62 typedef ValueType& Reference;
63 typedef std::ptrdiff_t KeyType;
69 struct PropertyMapTraits<const T*>
72 typedef const ValueType& Reference;
73 typedef std::ptrdiff_t KeyType;
74 typedef LvaluePropertyMapTag Category;
77 template<
class Reference,
class PropertyMap>
78 struct RAPropertyMapHelper
81 template<
class Reference,
class PropertyMap,
class Key>
83 get(
const RAPropertyMapHelper<Reference,PropertyMap>& pmap,
86 return static_cast<const PropertyMap&
>(pmap)[key];
89 template<
class Reference,
class PropertyMap,
class Key,
class Value>
91 put(
const RAPropertyMapHelper<Reference,PropertyMap>& pmap,
92 const Key& key,
const Value& value)
94 static_assert((Conversion<typename PropertyMap::Category,WritablePropertyMapTag>
95 ::exists),
"WritablePropertyMapTag required!");
96 static_cast<const PropertyMap&
>(pmap)[key] = value;
102 template<
class RAI,
class IM,
103 class T =
typename std::iterator_traits<RAI>::value_type,
104 class R =
typename std::iterator_traits<RAI>::reference>
106 :
public RAPropertyMapHelper<R,IteratorPropertyMap<RAI,IM,T,R> >
150 : iter_(iter), indexMap_(im)
155 : iter_(), indexMap_()
161 return *(iter_ + get(indexMap_, key));
177 : RAPropertyMapHelper<typename T::value_type::second_type&,
178 AssociativePropertyMap<T> >
183 typedef T UniqueAssociativeContainer;
188 typedef typename UniqueAssociativeContainer::value_type::first_type
194 typedef typename UniqueAssociativeContainer::value_type::second_type
200 typedef ValueType& Reference;
221 inline Reference operator[](KeyType key)
const
223 return map_->find(key)->second;
226 UniqueAssociativeContainer* map_;
235 : RAPropertyMapHelper<const typename T::value_type::second_type&,
236 ConstAssociativePropertyMap<T> >
241 typedef T UniqueAssociativeContainer;
246 typedef typename UniqueAssociativeContainer::value_type::first_type
252 typedef typename UniqueAssociativeContainer::value_type::second_type
258 typedef const ValueType& Reference;
279 inline Reference operator[](KeyType key)
const
281 return map_->find(key)->second;
284 const UniqueAssociativeContainer* map_;
291 :
public RAPropertyMapHelper<std::size_t, IdentityMap>
317 template<
typename T,
typename C>
An adapter to turn an unique associative container into a property map.
Definition: propertymap.hh:179
An adaptor to turn an unique associative container into a property map.
Definition: propertymap.hh:237
Adapter to turn a random access iterator into a property map.
Definition: propertymap.hh:107
IndexMap::KeyType KeyType
The key type of the property map.
Definition: propertymap.hh:124
R Reference
The reference type of the property map.
Definition: propertymap.hh:134
T ValueType
The value type of the property map.
Definition: propertymap.hh:129
Reference operator[](KeyType key) const
Access the a value by reference.
Definition: propertymap.hh:159
IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap())
Constructor.
Definition: propertymap.hh:148
IteratorPropertyMap()
Constructor.
Definition: propertymap.hh:154
IM IndexMap
The type of the index map.
Definition: propertymap.hh:119
RAI RandomAccessIterator
The type of the random access iterator.
Definition: propertymap.hh:112
LvaluePropertyMapTag Category
The category of this property map.
Definition: propertymap.hh:139
Dune namespace.
Definition: alignment.hh:10
A property map that applies the identity function to integers.
Definition: propertymap.hh:292
std::size_t ValueType
The value type of the map.
Definition: propertymap.hh:297
std::size_t KeyType
The key type of the map.
Definition: propertymap.hh:294
std::size_t Reference
The reference type of the map.
Definition: propertymap.hh:300
ReadablePropertyMapTag Category
The category of the map.
Definition: propertymap.hh:303
Tag for the category of lvalue property maps.
Definition: propertymap.hh:56
Selector for the property map type.
Definition: propertymap.hh:319
T Tag
the tag identifying the property.
Definition: propertymap.hh:323
C Container
The container type to whose entries the properties are attached.
Definition: propertymap.hh:328
Tag for the category of readable and writable property maps.
Definition: propertymap.hh:49
Tag for the category of readable property maps.
Definition: propertymap.hh:37
Tag for the category of writable property maps.
Definition: propertymap.hh:41
Traits for type conversions and type information.