dune-grid  2.3beta2
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