Dune Core Modules (2.8.0)

intersectioniterator.hh
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_COMMON_INTERSECTIONITERATOR_HH
4#define DUNE_GRID_COMMON_INTERSECTIONITERATOR_HH
5
8
9#include <dune/grid/common/intersection.hh>
10
11namespace Dune
12{
13
79 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
81 {
82 public:
88 typedef IntersectionIteratorImp Implementation;
89
95 Implementation &impl () { return realIterator; }
96
102 const Implementation &impl () const { return realIterator; }
103
104 protected:
105 Implementation realIterator;
106
107 public:
110
111 //===========================================================
115 //===========================================================
116
117 // The behavior when dereferencing the IntersectionIterator facade depends on
118 // the way the grid implementation handles returning intersections. The implementation
119 // may either return a reference to an intersection stored inside the IntersectionIterator
120 // implementation or a temporary Intersection object. This object has to be forwarded through
121 // the facade to the user, which requires a little trickery, especially for operator->().
122 //
123 // In order to avoid confusing users reading the Doxygen documentation, we provide "clean"
124 // function signatures to Doxygen and hide the actual implementations.
125
126#ifdef DOXYGEN
127
130
132 const Intersection* operator->() const;
133
134#else // DOXYGEN
135
137 typename std::conditional<
138 std::is_lvalue_reference<
139 decltype(realIterator.dereference())
140 >::value,
141 const Intersection&,
143 >::type
144 operator*() const
145 {
146 return this->realIterator.dereference();
147 }
148
150 decltype(handle_proxy_member_access(realIterator.dereference()))
151 operator->() const
152 {
153 return handle_proxy_member_access(realIterator.dereference());
154 }
155
156#endif // DOXYGEN
157
159
160
161 //===========================================================
165 //===========================================================
166
172 bool operator==(const IntersectionIterator& rhs) const
173 {
174 return rhs.equals(*this);
175 }
176
182 bool operator!=(const IntersectionIterator& rhs) const
183 {
184 return ! rhs.equals(*this);
185 }
187
190 {
191 this->realIterator.increment();
192 return *this;
193 }
194
197 {
198 IntersectionIterator copy(*this);
199 this->realIterator.increment();
200 return copy;
201 }
202
205 {}
206
207 //===========================================================
211 //===========================================================
212
214 bool equals(const IntersectionIterator& rhs) const
215 {
216 return this->realIterator.equals(rhs.realIterator);
217 }
218
221 : realIterator( impl )
222 {}
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;
236 typedef const typename Dune::Intersection< GridImp, IntersectionImp > value_type;
237 typedef value_type *pointer;
238 typedef value_type &reference;
239 typedef forward_iterator_tag iterator_category;
240 };
241
242} // namespace std
243
244#include "intersection.hh"
245
246#endif // DUNE_GRID_COMMON_INTERSECTIONITERATOR_HH
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:81
IntersectionIterator()
Default constructor.
Definition: intersectioniterator.hh:204
const Intersection * operator->() const
Pointer operator.
IntersectionIterator & operator++()
Preincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:189
IntersectionIteratorImp Implementation
type of underlying implementation
Definition: intersectioniterator.hh:88
Intersection operator*() const
Dereferencing operator.
bool operator==(const IntersectionIterator &rhs) const
Checks for equality. Only Iterators pointing to the same intersection from the same Entity are equal....
Definition: intersectioniterator.hh:172
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition: intersectioniterator.hh:109
IntersectionIterator operator++(int)
Postincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:196
Implementation & impl()
access to the underlying implementation
Definition: intersectioniterator.hh:95
const Implementation & impl() const
access to the underlying implementation
Definition: intersectioniterator.hh:102
bool operator!=(const IntersectionIterator &rhs) const
Checks for inequality. Only Iterators pointing to the same intersection from the same Entity are equa...
Definition: intersectioniterator.hh:182
IntersectionIterator(const Implementation &impl)
Definition: intersectioniterator.hh:220
bool equals(const IntersectionIterator &rhs) const
forward equality check to realIterator
Definition: intersectioniterator.hh:214
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:162
pointer_or_proxy_holder handle_proxy_member_access(T &&t)
Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
This file implements iterator facade classes for writing stl conformant iterators.
Dune namespace.
Definition: alignedallocator.hh:11
STL namespace.
infrastructure for supporting operator->() on both references and proxies
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)