dune-grid  2.2.0
common/intersectioniterator.hh
Go to the documentation of this file.
00001 #ifndef DUNE_GRID_INTERSECTIONITERATOR_HH
00002 #define DUNE_GRID_INTERSECTIONITERATOR_HH
00003 
00004 #include <dune/common/iteratorfacades.hh>
00005 
00006 #include <dune/grid/common/intersection.hh>
00007 
00008 namespace Dune
00009 {
00010 
00087 template<class GridImp, template<class> class IntersectionIteratorImp, template<class> class IntersectionImp>
00088 class IntersectionIterator
00089 {
00090 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
00091 public:
00092 #else
00093 protected:
00094   // give the GridDefaultImplementation class access to the realImp 
00095   friend class GridDefaultImplementation< 
00096             GridImp::dimension, GridImp::dimensionworld,
00097             typename GridImp::ctype,
00098             typename GridImp::GridFamily> ;
00099 #endif
00100   // type of underlying implementation, for internal use only 
00101   typedef IntersectionIteratorImp< const GridImp > Implementation;
00102 
00104   Implementation &impl () { return realIterator; }
00106   const Implementation &impl () const { return realIterator; }
00107 
00108 protected:
00109   Implementation realIterator;
00110 
00111 public:
00113   typedef Dune::Intersection< const GridImp, IntersectionImp > Intersection;
00114 
00115   //===========================================================
00119   //===========================================================
00120 
00122   const Intersection & operator*() const
00123     {
00124       return this->realIterator.dereference();
00125     }
00126 
00128   const Intersection * operator->() const
00129     {
00130       return & this->realIterator.dereference();
00131     }
00133 
00134 
00135   //===========================================================
00139   //===========================================================
00140 
00146   bool operator==(const IntersectionIterator& rhs) const
00147     {
00148       return rhs.equals(*this);
00149     }
00150 
00156   bool operator!=(const IntersectionIterator& rhs) const
00157     {
00158       return ! rhs.equals(*this);
00159     }
00161 
00163   IntersectionIterator& operator++()
00164     {
00165       this->realIterator.increment();
00166       return *this;
00167     }
00168   
00169   //===========================================================
00173   //===========================================================
00174 
00176   bool equals(const IntersectionIterator& rhs) const
00177     {
00178       return this->realIterator.equals(rhs.realIterator);
00179     }
00180 
00182   IntersectionIterator(const IntersectionIteratorImp<const GridImp> & i) :
00183     realIterator(i) {};
00184 
00186   IntersectionIterator(const IntersectionIterator& i) :
00187     realIterator(i.realIterator) {}
00189 
00190   typedef typename remove_const<GridImp>::type mutableGridImp;
00191 };
00192 
00193 } // namespace Dune
00194 
00195 #include "intersection.hh"
00196 
00197 #endif // DUNE_GRID_INTERSECTIONITERATOR_HH