Dune Core Modules (2.9.1)

intersectioniterator.hh
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_GRID_COMMON_INTERSECTIONITERATOR_HH
6#define DUNE_GRID_COMMON_INTERSECTIONITERATOR_HH
7
10
11#include <dune/grid/common/intersection.hh>
12
13namespace Dune
14{
15
81 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
83 {
84 public:
90 typedef IntersectionIteratorImp Implementation;
91
97 Implementation &impl () { return realIterator; }
98
104 const Implementation &impl () const { return realIterator; }
105
106 protected:
107 Implementation realIterator;
108
109 public:
112
113 //===========================================================
117 //===========================================================
118
119 // The behavior when dereferencing the IntersectionIterator facade depends on
120 // the way the grid implementation handles returning intersections. The implementation
121 // may either return a reference to an intersection stored inside the IntersectionIterator
122 // implementation or a temporary Intersection object. This object has to be forwarded through
123 // the facade to the user, which requires a little trickery, especially for operator->().
124 //
125 // In order to avoid confusing users reading the Doxygen documentation, we provide "clean"
126 // function signatures to Doxygen and hide the actual implementations.
127
128#ifdef DOXYGEN
129
132
134 const Intersection* operator->() const;
135
136#else // DOXYGEN
137
139 typename std::conditional<
140 std::is_lvalue_reference<
141 decltype(realIterator.dereference())
142 >::value,
143 const Intersection&,
145 >::type
146 operator*() const
147 {
148 return this->realIterator.dereference();
149 }
150
152 decltype(handle_proxy_member_access(realIterator.dereference()))
153 operator->() const
154 {
155 return handle_proxy_member_access(realIterator.dereference());
156 }
157
158#endif // DOXYGEN
159
161
162
163 //===========================================================
167 //===========================================================
168
174 bool operator==(const IntersectionIterator& rhs) const
175 {
176 return rhs.equals(*this);
177 }
178
184 bool operator!=(const IntersectionIterator& rhs) const
185 {
186 return ! rhs.equals(*this);
187 }
189
192 {
193 this->realIterator.increment();
194 return *this;
195 }
196
199 {
200 IntersectionIterator copy(*this);
201 this->realIterator.increment();
202 return copy;
203 }
204
207 {}
208
209 //===========================================================
213 //===========================================================
214
216 bool equals(const IntersectionIterator& rhs) const
217 {
218 return this->realIterator.equals(rhs.realIterator);
219 }
220
223 : realIterator( impl )
224 {}
226 };
227
228} // namespace Dune
229
230
231namespace std
232{
233
234 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
235 struct iterator_traits< Dune::IntersectionIterator< GridImp, IntersectionIteratorImp, IntersectionImp > >
236 {
237 typedef ptrdiff_t difference_type;
238 typedef const typename Dune::Intersection< GridImp, IntersectionImp > value_type;
239 typedef value_type *pointer;
240 typedef value_type &reference;
241 typedef forward_iterator_tag iterator_category;
242 };
243
244} // namespace std
245
246#include "intersection.hh"
247
248#endif // DUNE_GRID_COMMON_INTERSECTIONITERATOR_HH
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
IntersectionIterator()
Default constructor.
Definition: intersectioniterator.hh:206
const Intersection * operator->() const
Pointer operator.
IntersectionIterator & operator++()
Preincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:191
IntersectionIteratorImp Implementation
type of underlying implementation
Definition: intersectioniterator.hh:90
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:174
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition: intersectioniterator.hh:111
IntersectionIterator operator++(int)
Postincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:198
Implementation & impl()
access to the underlying implementation
Definition: intersectioniterator.hh:97
const Implementation & impl() const
access to the underlying implementation
Definition: intersectioniterator.hh:104
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:184
IntersectionIterator(const Implementation &impl)
Definition: intersectioniterator.hh:222
bool equals(const IntersectionIterator &rhs) const
forward equality check to realIterator
Definition: intersectioniterator.hh:216
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
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:13
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)