4#ifndef DUNE_PROPERTYMAP_HH
5#define DUNE_PROPERTYMAP_HH
17 struct PropertyMapTraits
22 typedef typename PM::KeyType KeyType;
26 typedef typename PM::ValueType ValueType;
30 typedef typename PM::Reference Reference;
34 typedef typename PM::Category Category;
61 struct PropertyMapTraits<T*>
64 typedef ValueType& Reference;
65 typedef std::ptrdiff_t KeyType;
71 struct PropertyMapTraits<const T*>
74 typedef const ValueType& Reference;
75 typedef std::ptrdiff_t KeyType;
76 typedef LvaluePropertyMapTag Category;
79 template<
class Reference,
class PropertyMap>
80 struct RAPropertyMapHelper
83 template<
class Reference,
class PropertyMap,
class Key>
85 get(
const RAPropertyMapHelper<Reference,PropertyMap>& pmap,
88 return static_cast<const PropertyMap&
>(pmap)[key];
91 template<
class Reference,
class PropertyMap,
class Key,
class Value>
93 put(
const RAPropertyMapHelper<Reference,PropertyMap>& pmap,
94 const Key& key,
const Value& value)
97 ::exists),
"WritablePropertyMapTag required!");
98 static_cast<const PropertyMap&
>(pmap)[key] = value;
104 template<
class RAI,
class IM,
105 class T =
typename std::iterator_traits<RAI>::value_type,
106 class R =
typename std::iterator_traits<RAI>::reference>
108 :
public RAPropertyMapHelper<R,IteratorPropertyMap<RAI,IM,T,R> >
152 : iter_(iter), indexMap_(im)
157 : iter_(), indexMap_()
163 return *(iter_ + get(indexMap_, key));
179 : RAPropertyMapHelper<typename T::value_type::second_type&,
180 AssociativePropertyMap<T> >
185 typedef T UniqueAssociativeContainer;
190 typedef typename UniqueAssociativeContainer::value_type::first_type
196 typedef typename UniqueAssociativeContainer::value_type::second_type
202 typedef ValueType& Reference;
223 inline Reference operator[](KeyType key)
const
225 return map_->find(key)->second;
228 UniqueAssociativeContainer* map_;
237 : RAPropertyMapHelper<const typename T::value_type::second_type&,
238 ConstAssociativePropertyMap<T> >
243 typedef T UniqueAssociativeContainer;
248 typedef typename UniqueAssociativeContainer::value_type::first_type
254 typedef typename UniqueAssociativeContainer::value_type::second_type
260 typedef const ValueType& Reference;
281 inline Reference operator[](KeyType key)
const
283 return map_->find(key)->second;
286 const UniqueAssociativeContainer* map_;
293 :
public RAPropertyMapHelper<std::size_t, IdentityMap>
319 template<
typename T,
typename C>
An adapter to turn an unique associative container into a property map.
Definition: propertymap.hh:181
An adaptor to turn an unique associative container into a property map.
Definition: propertymap.hh:239
Adapter to turn a random access iterator into a property map.
Definition: propertymap.hh:109
IndexMap::KeyType KeyType
The key type of the property map.
Definition: propertymap.hh:126
R Reference
The reference type of the property map.
Definition: propertymap.hh:136
T ValueType
The value type of the property map.
Definition: propertymap.hh:131
Reference operator[](KeyType key) const
Access the a value by reference.
Definition: propertymap.hh:161
IteratorPropertyMap(RandomAccessIterator iter, const IndexMap &im=IndexMap())
Constructor.
Definition: propertymap.hh:150
IteratorPropertyMap()
Constructor.
Definition: propertymap.hh:156
IM IndexMap
The type of the index map.
Definition: propertymap.hh:121
RAI RandomAccessIterator
The type of the random access iterator.
Definition: propertymap.hh:114
LvaluePropertyMapTag Category
The category of this property map.
Definition: propertymap.hh:141
#define dune_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
Dune namespace.
Definition: alignment.hh:14
Fallback implementation of the C++0x static_assert feature.
A property map that applies the identity function to integers.
Definition: propertymap.hh:294
std::size_t ValueType
The value type of the map.
Definition: propertymap.hh:299
std::size_t KeyType
The key type of the map.
Definition: propertymap.hh:296
std::size_t Reference
The reference type of the map.
Definition: propertymap.hh:302
ReadablePropertyMapTag Category
The category of the map.
Definition: propertymap.hh:305
Tag for the category of lvalue property maps.
Definition: propertymap.hh:58
Selector for the property map type.
Definition: propertymap.hh:321
T Tag
the tag identifying the property.
Definition: propertymap.hh:325
C Container
The container type to whose entries the properties are attached.
Definition: propertymap.hh:330
Tag for the category of readable and writable property maps.
Definition: propertymap.hh:51
Tag for the category of readable property maps.
Definition: propertymap.hh:39
Tag for the category of writable property maps.
Definition: propertymap.hh:43
Traits for type conversions and type information.