Dune Core Modules (2.3.1)

entitypointer.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_ENTITYPOINTER_HH
4#define DUNE_GRID_ENTITYPOINTER_HH
5
8
13namespace Dune
14{
15
90 template<class GridImp, class IteratorImp>
92 {
93 // need to make copy constructor of EntityPointer work for any iterator
94 //friend class EntityPointer<GridImp,typename IteratorImp::EntityPointerImp>;
95 template< class, class > friend class EntityPointer;
96
97#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
98 public:
99#else
100 protected:
101 // give the GridDefaultImplementation class access to the realImp
102 friend class GridDefaultImplementation<
103 GridImp::dimension, GridImp::dimensionworld,
104 typename GridImp::ctype,
105 typename GridImp::GridFamily> ;
106#endif
107 // type of underlying implementation, for internal use only
108 typedef IteratorImp Implementation;
109
111 Implementation &impl () { return realIterator; }
113 const Implementation &impl () const { return realIterator; }
114
115 protected:
116 Implementation realIterator;
117
118 public:
120 enum { codimension = IteratorImp::codimension };
121
123 typedef typename IteratorImp::Entity Entity;
124
125 enum {
127 codim = IteratorImp::codimension
128 };
129
130 //===========================================================
134 //===========================================================
135
142 template< class ItImp >
144 : realIterator( ep.realIterator )
145 {}
146
153 EntityPointer(const Entity& entity)
154 : realIterator( entity.impl() )
155 {}
156
162 EntityPointer ( const typename Entity::Implementation &entityImp )
163 : realIterator( entityImp )
164 {}
165
166 template< class ItImp >
167 EntityPointer &operator= ( const EntityPointer< GridImp, ItImp > &ep )
168 {
169 realIterator = ep.realIterator;
170 return *this;
171 }
172
174
175 //===========================================================
179 //===========================================================
180
183 {
184 return realIterator.dereference();
185 }
186
189 {
190 return & realIterator.dereference();
191 }
193
194 //===========================================================
198 //===========================================================
199
205 template< class ItImp >
207 {
208 return equals( rhs );
209 }
210
216 template< class ItImp >
218 {
219 return !equals( rhs );
220 }
222
223
224 //===========================================================
228 //===========================================================
229
235 int level () const
236 {
237 return realIterator.level();
238 }
239
241
242
243 //===========================================================
247 //===========================================================
248
249
255 EntityPointer(const IteratorImp & i) :
256 realIterator(i) {}
257
259 template< class ItImp >
260 bool equals ( const EntityPointer< GridImp, ItImp > &rhs ) const
261 {
262 return realIterator.equals( rhs.realIterator );
263 }
265 };
266
267}
268
269#endif // DUNE_GRID_ENTITYPOINTER_HH
Wrapper class for pointers to entities.
Definition: entitypointer.hh:92
@ codim
The codimension of this EntityPointer.
Definition: entitypointer.hh:127
EntityPointer(const Entity &entity)
Templatized constructor from type of entity that this entity pointer points to. This constructor can ...
Definition: entitypointer.hh:153
bool operator==(const EntityPointer< GridImp, ItImp > &rhs) const
Checks for equality. Only works for EntityPointers and iterators on the same grid....
Definition: entitypointer.hh:206
Entity & operator*() const
Dereferencing operator.
Definition: entitypointer.hh:182
EntityPointer(const IteratorImp &i)
Copy Constructor from an Iterator implementation.
Definition: entitypointer.hh:255
IteratorImp::Entity Entity
The Entity that this EntityPointer can point to.
Definition: entitypointer.hh:123
EntityPointer(const EntityPointer< GridImp, ItImp > &ep)
Templatized copy constructor from arbitrary IteratorImp. This enables that an EntityPointer can be co...
Definition: entitypointer.hh:143
Entity * operator->() const
Pointer operator.
Definition: entitypointer.hh:188
int level() const
Ask for level of entity. This method is redundant and is only there for efficiency reasons....
Definition: entitypointer.hh:235
Implementation & impl()
return reference to the real implementation
Definition: entitypointer.hh:111
EntityPointer(const typename Entity::Implementation &entityImp)
Constructor from type of entity implementation that this entity pointer points to....
Definition: entitypointer.hh:162
bool equals(const EntityPointer< GridImp, ItImp > &rhs) const
Forward equality check to realIterator.
Definition: entitypointer.hh:260
const Implementation & impl() const
return reference to the real implementation
Definition: entitypointer.hh:113
bool operator!=(const EntityPointer< GridImp, ItImp > &rhs) const
Checks for inequality. Only works for EntityPointers and iterators on the same grid....
Definition: entitypointer.hh:217
Definition: grid.hh:1017
Different resources needed by all grid implementations.
This file implements iterator facade classes for writing stl conformant iterators.
Dune namespace.
Definition: alignment.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)