dune-grid 3.0-git
common/intersectioniterator.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_INTERSECTIONITERATOR_HH
4#define DUNE_GRID_INTERSECTIONITERATOR_HH
5
6#include <dune/common/iteratorfacades.hh>
7#include <dune/common/proxymemberaccess.hh>
8
10
11namespace Dune
12{
13
79 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
81 {
82#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
83 public:
84#else
85 protected:
86 // give the GridDefaultImplementation class access to the realImp
87 friend class GridDefaultImplementation<
88 GridImp::dimension, GridImp::dimensionworld,
89 typename GridImp::ctype,
90 typename GridImp::GridFamily> ;
91#endif
92 // type of underlying implementation, for internal use only
93 typedef IntersectionIteratorImp Implementation;
94
96 Implementation &impl () { return realIterator; }
98 const Implementation &impl () const { return realIterator; }
99
100 protected:
102
103 public:
106
107 //===========================================================
111 //===========================================================
112
113 // The behavior when dereferencing the IntersectionIterator facade depends on
114 // the way the grid implementation handles returning intersections. The implementation
115 // may either return a reference to an intersection stored inside the IntersectionIterator
116 // implementation or a temporary Intersection object. This object has to be forwarded through
117 // the facade to the user, which requires a little trickery, especially for operator->().
118 //
119 // In order to avoid confusing users reading the Doxygen documentation, we provide "clean"
120 // function signatures to Doxygen and hide the actual implementations.
121
122#ifdef DOXYGEN
123
126
128 const Intersection* operator->() const;
129
130#else // DOXYGEN
131
133 typename std::conditional<
134 std::is_lvalue_reference<
135 decltype(realIterator.dereference())
136 >::value,
137 const Intersection&,
139 >::type
140 operator*() const
141 {
142 return this->realIterator.dereference();
143 }
144
146 decltype(handle_proxy_member_access(realIterator.dereference()))
147 operator->() const
148 {
149 return handle_proxy_member_access(realIterator.dereference());
150 }
151
152#endif // DOXYGEN
153
155
156
157 //===========================================================
161 //===========================================================
162
168 bool operator==(const IntersectionIterator& rhs) const
169 {
170 return rhs.equals(*this);
171 }
172
178 bool operator!=(const IntersectionIterator& rhs) const
179 {
180 return ! rhs.equals(*this);
181 }
183
186 {
187 this->realIterator.increment();
188 return *this;
189 }
190
193 {
194 IntersectionIterator copy(*this);
195 this->realIterator.increment();
196 return copy;
197 }
198
202
203 //===========================================================
207 //===========================================================
208
210 bool equals(const IntersectionIterator& rhs) const
211 {
212 return this->realIterator.equals(rhs.realIterator);
213 }
214
219
224 };
225
226} // namespace Dune
227
228
229namespace std
230{
231
232 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
233 struct iterator_traits< Dune::IntersectionIterator< GridImp, IntersectionIteratorImp, IntersectionImp > >
234 {
235 typedef ptrdiff_t difference_type;
239 typedef forward_iterator_tag iterator_category;
240 };
241
242} // namespace std
243
244#include "intersection.hh"
245
246#endif // DUNE_GRID_INTERSECTIONITERATOR_HH
STL namespace.
Include standard header files.
Definition agrid.hh:60
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition common/intersection.hh:162
Definition common/grid.hh:924
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition common/intersectioniterator.hh:81
IntersectionIterator()
Default constructor.
Definition common/intersectioniterator.hh:200
const Intersection * operator->() const
Pointer operator.
IntersectionIterator & operator++()
Preincrement operator. Proceed to next intersection.
Definition common/intersectioniterator.hh:185
IntersectionIteratorImp Implementation
Definition common/intersectioniterator.hh:93
Intersection operator*() const
Dereferencing operator.
IntersectionIterator(const IntersectionIterator &i)
Definition common/intersectioniterator.hh:221
bool operator==(const IntersectionIterator &rhs) const
Checks for equality. Only Iterators pointing to the same intersection from the same Entity are equal....
Definition common/intersectioniterator.hh:168
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition common/intersectioniterator.hh:105
IntersectionIterator operator++(int)
Postincrement operator. Proceed to next intersection.
Definition common/intersectioniterator.hh:192
Implementation & impl()
return reference to the real implementation
Definition common/intersectioniterator.hh:96
Implementation realIterator
Definition common/intersectioniterator.hh:101
const Implementation & impl() const
return reference to the real implementation
Definition common/intersectioniterator.hh:98
bool operator!=(const IntersectionIterator &rhs) const
Checks for inequality. Only Iterators pointing to the same intersection from the same Entity are equa...
Definition common/intersectioniterator.hh:178
IntersectionIterator(const Implementation &impl)
Definition common/intersectioniterator.hh:216
bool equals(const IntersectionIterator &rhs) const
forward equality check to realIterator
Definition common/intersectioniterator.hh:210
forward_iterator_tag iterator_category
Definition common/intersectioniterator.hh:239
const Dune::Intersection< GridImp, IntersectionImp > value_type
Definition common/intersectioniterator.hh:236