Dune Core Modules (2.4.2)

entityiterator.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_ENTITYITERATOR_HH
4#define DUNE_GRID_ENTITYITERATOR_HH
5
6#include <cstddef>
7#include <iterator>
8
10
11namespace Dune
12{
13
34 template< int codim, class Grid, class IteratorImp >
36 : public EntityPointer< Grid, IteratorImp >
37 {
39
40 protected:
41 using Base::realIterator;
42
43 public:
44 typedef typename Grid::template Codim< codim >::Entity Entity;
45
48 {
49 realIterator.increment();
50 return *this;
51 }
52
55 {
56 EntityIterator tmp(*this);
57 realIterator.increment();
58 return tmp;
59 }
60
61 // The dereferencing operators are overridden here to avoid calling
62 // the deprecated versions int the EntityPointer facade.
63
64 // The behavior when dereferencing the EntityIterator facade depends on
65 // the way the grid implementation handles returning entities. The implementation
66 // may either return a reference to an entity stored inside the EntityIterator
67 // implementation or a temporary Entity object. This object has to be forwarded through
68 // the facade to the user, which requires a little trickery, especially for operator->().
69 //
70 // In order to avoid confusing users reading the Doxygen documentation, we provide "clean"
71 // function signatures to Doxygen and hide the actual implementations.
72
73
74#ifdef DOXYGEN
75
77 const Entity& operator*() const;
78
80 const Entity* operator->() const;
81
82#else // DOXYGEN
83
85 typename std::conditional<
86 std::is_lvalue_reference<
87 decltype(realIterator.dereference())
88 >::value,
89 const Entity&,
90 Entity
91 >::type
92 operator*() const
93 {
94 return realIterator.dereference();
95 }
96
98 decltype(handle_proxy_member_access(realIterator.dereference()))
99 operator->() const
100 {
101 return handle_proxy_member_access(realIterator.dereference());
102 }
103
104#endif // DOXYGEN
105
106
108 bool operator==(const EntityIterator& rhs) const
109 {
110 return this->realIterator.equals(rhs.realIterator);
111 }
112
114 bool operator!=(const EntityIterator& rhs) const
115 {
116 return !this->realIterator.equals(rhs.realIterator);
117 }
118
128 template< class ItImp >
129 DUNE_DEPRECATED_MSG("Comparing different types of iterators is deprecated and will be removed after the \
130release of dune-grid 2.4. If you want to compare the entities pointed at by the iterators, dereference the \
131iterators before comparing them.")
132 bool operator== ( const EntityIterator< codim, Grid, ItImp > &rhs ) const
133 {
134 return this->equals( rhs );
135 }
136
146 template< class ItImp >
147 DUNE_DEPRECATED_MSG("Comparing different types of iterators is deprecated and will be removed after the \
148release of dune-grid 2.4. If you want to compare the entities pointed at by the iterators, dereference the \
149iterators before comparing them.")
150 bool operator!= ( const EntityIterator< codim, Grid, ItImp > &rhs ) const
151 {
152 return !this->equals( rhs );
153 }
154
164 template< class ItImp >
165 DUNE_DEPRECATED_MSG("EntityPointer is deprecated will be removed after the release of dune-grid 2.4. \
166Moreover, comparing different types of iterators is deprecated as well and will also be removed after the \
167release of dune-grid 2.4. If you want to compare the entities pointed at by the iterators, dereference the \
168iterators before comparing them.")
169 bool operator== ( const EntityPointer< Grid, ItImp > &rhs ) const
170 {
171 return this->equals( rhs );
172 }
173
183 template< class ItImp >
184 DUNE_DEPRECATED_MSG("EntityPointer is deprecated will be removed after the release of dune-grid 2.4. \
185Moreover, comparing different types of iterators is deprecated as well and will also be removed after the \
186release of dune-grid 2.4. If you want to compare the entities pointed at by the iterators, dereference the \
187iterators before comparing them.")
188 bool operator!= ( const EntityPointer< Grid, ItImp > &rhs ) const
189 {
190 return !this->equals( rhs );
191 }
192
193
199 DUNE_DEPRECATED_MSG("EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. \
200Instead, you can copy and store entities directly now. You probably stumbled across this warning because you \
201compared the return value of Entity::father(), Entity::subEntity(), Intersection::inside() or \
202Intersection::outside() with an iterator. To fix the problem, derefence the iterator before comparing.")
203 bool operator==(const Entity& rhs) const
204 {
205 return (**this) == rhs;
206 }
207
213 DUNE_DEPRECATED_MSG("EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. \
214Instead, you can copy and store entities directly now. You probably stumbled across this warning because you \
215compared the return value of Entity::father(), Entity::subEntity(), Intersection::inside() or \
216Intersection::outside() with an iterator. To fix the problem, derefence the iterator before comparing.")
217 bool operator!=(const Entity& rhs) const
218 {
219 return (**this) != rhs;
220 }
221
222
228 EntityIterator ( )
229 {}
230
232 EntityIterator ( const IteratorImp &imp )
233 : Base( imp )
234 {}
235
237 };
238
239} // namespace Dune
240
241namespace std
242{
243
244 template< int codim, class Grid, class IteratorImp >
245 struct iterator_traits< Dune::EntityIterator< codim, Grid, IteratorImp > >
246 {
247 typedef ptrdiff_t difference_type;
248 typedef const typename IteratorImp::Entity value_type;
249 typedef value_type *pointer;
250 typedef value_type &reference;
251 typedef forward_iterator_tag iterator_category;
252 };
253
254} // namespace std
255
256#endif // #ifndef DUNE_GRID_ENTITYITERATOR_HH
interface class for an iterator over grid entities
Definition: entityiterator.hh:37
const Entity * operator->() const
Pointer operator.
const Entity & operator*() const
Dereferencing operator.
bool operator!=(const EntityIterator &rhs) const
Checks for inequality.
Definition: entityiterator.hh:114
EntityIterator & operator++()
prefix increment operator
Definition: entityiterator.hh:47
bool operator==(const EntityIterator &rhs) const
Checks for equality.
Definition: entityiterator.hh:108
Wrapper class for pointers to entities.
Definition: entitypointer.hh:113
EntityPointer()
Default constructor of an empty (undefined) EntityPointer.
Definition: entitypointer.hh:173
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entitypointer.hh:432
bool equals(const EntityPointer< Grid, ItImp > &rhs) const
Forward equality check to realIterator.
Definition: entitypointer.hh:362
Grid abstract base class.
Definition: grid.hh:388
Wrapper and interface class for a static iterator (EntityPointer)
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Dune namespace.
Definition: alignment.hh:10
pointer_or_proxy_holder handle_proxy_member_access(T &&t)
Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 20, 23:31, 2024)