dune-grid  2.3.1-rc1
common/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 
6 #include <dune/common/iteratorfacades.hh>
8 
13 namespace 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 
113  const Implementation &impl () const { return realIterator; }
114 
115  protected:
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 >
168  {
170  return *this;
171  }
172 
174 
175  //===========================================================
179  //===========================================================
180 
182  Entity & operator*() const
183  {
184  return realIterator.dereference();
185  }
186 
188  Entity * operator->() const
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
EntityPointer(const Entity &entity)
Templatized constructor from type of entity that this entity pointer points to. This constructor can ...
Definition: common/entitypointer.hh:153
EntityPointer & operator=(const EntityPointer< GridImp, ItImp > &ep)
Definition: common/entitypointer.hh:167
EntityPointer(const typename Entity::Implementation &entityImp)
Constructor from type of entity implementation that this entity pointer points to. This constructor is only used in the EntityDefaultImplementation to implement the method seed() by default when the type of EntitySeed and EntityPointer coniside.
Definition: common/entitypointer.hh:162
EntityPointer(const EntityPointer< GridImp, ItImp > &ep)
Templatized copy constructor from arbitrary IteratorImp. This enables that an EntityPointer can be co...
Definition: common/entitypointer.hh:143
bool operator==(const EntityPointer< GridImp, ItImp > &rhs) const
Checks for equality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer.
Definition: common/entitypointer.hh:206
Wrapper class for pointers to entities.
Definition: common/entitypointer.hh:91
IteratorImp Implementation
Definition: common/entitypointer.hh:108
int level() const
Ask for level of entity. This method is redundant and is only there for efficiency reasons...
Definition: common/entitypointer.hh:235
EntityImp< cd, dim, GridImp > Implementation
Definition: common/entity.hh:73
Implementation realIterator
Definition: common/entitypointer.hh:116
Implementation & impl()
return reference to the real implementation
Definition: common/entitypointer.hh:111
Entity * operator->() const
Pointer operator.
Definition: common/entitypointer.hh:188
bool equals(const EntityPointer< GridImp, ItImp > &rhs) const
Forward equality check to realIterator.
Definition: common/entitypointer.hh:260
Different resources needed by all grid implementations.
Entity & operator*() const
Dereferencing operator.
Definition: common/entitypointer.hh:182
The codimension of this EntityPointer.
Definition: common/entitypointer.hh:127
Definition: common/geometry.hh:24
bool operator!=(const EntityPointer< GridImp, ItImp > &rhs) const
Checks for inequality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer.
Definition: common/entitypointer.hh:217
const Implementation & impl() const
return reference to the real implementation
Definition: common/entitypointer.hh:113
IteratorImp::Entity Entity
The Entity that this EntityPointer can point to.
Definition: common/entitypointer.hh:123
Definition: common/entitypointer.hh:120
EntityPointer(const IteratorImp &i)
Copy Constructor from an Iterator implementation.
Definition: common/entitypointer.hh:255