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   IntersectionIteratorImp<const GridImp> realIterator;
00091 
00092 public:
00093   
00094   // type of real implementation 
00095   typedef IntersectionIteratorImp<const GridImp> ImplementationType;
00096   
00098   typedef Dune::Intersection< const GridImp, IntersectionImp > Intersection;
00099 
00100   //===========================================================
00104   //===========================================================
00105 
00107   const Intersection & operator*() const
00108     {
00109       return this->realIterator.dereference();
00110     }
00111 
00113   const Intersection * operator->() const
00114     {
00115       return & this->realIterator.dereference();
00116     }
00118 
00119 
00120   //===========================================================
00124   //===========================================================
00125 
00131   bool operator==(const IntersectionIterator& rhs) const
00132     {
00133       return rhs.equals(*this);
00134     }
00135 
00141   bool operator!=(const IntersectionIterator& rhs) const
00142     {
00143       return ! rhs.equals(*this);
00144     }
00146 
00148   IntersectionIterator& operator++()
00149     {
00150       this->realIterator.increment();
00151       return *this;
00152     }
00153   
00154   //===========================================================
00158   //===========================================================
00159 
00161   bool equals(const IntersectionIterator& rhs) const
00162     {
00163       return this->realIterator.equals(rhs.realIterator);
00164     }
00165 
00167   IntersectionIterator(const IntersectionIteratorImp<const GridImp> & i) :
00168     realIterator(i) {};
00169 
00171   IntersectionIterator(const IntersectionIterator& i) :
00172     realIterator(i.realIterator) {}
00174 
00175   typedef typename remove_const<GridImp>::type mutableGridImp;
00176 protected:
00177   // give the GridDefaultImplementation class access to the realImp 
00178   friend class GridDefaultImplementation<
00179             GridImp::dimension, GridImp::dimensionworld,
00180             typename GridImp::ctype,
00181             typename GridImp::GridFamily> ;
00182 
00184   ImplementationType & getRealImp() { return realIterator; }
00186   const ImplementationType & getRealImp() const { return realIterator; }
00187 
00188 };
00189 
00200 template<class GridImp, template<class> class IntersectionIteratorImp>
00201 class IntersectionIterator<GridImp, IntersectionIteratorImp, IntersectionIteratorImp>
00202 {
00203   
00204   Dune::Intersection<const GridImp, IntersectionIteratorImp> intersection;
00205 
00206 public:
00207   
00208   typedef IntersectionIteratorImp<const GridImp> ImplementationType;
00209   
00210   typedef Dune::Intersection<const GridImp, IntersectionIteratorImp> Intersection;
00211 
00212   const Intersection & operator*() const
00213   {
00214     return intersection;
00215   }
00216 
00217   const Intersection * operator->() const
00218   {
00219     return & intersection;
00220   }
00221 
00222   bool operator==(const IntersectionIterator& rhs) const
00223   {
00224     return rhs.equals(*this);
00225   }
00226 
00227   bool operator!=(const IntersectionIterator& rhs) const
00228   {
00229     return ! rhs.equals(*this);
00230   }
00231 
00232   IntersectionIterator& operator++()
00233   {
00234     getRealImp().increment();
00235     return *this;
00236   }
00237   
00238   bool equals(const IntersectionIterator& rhs) const
00239   {
00240     return getRealImp().equals(rhs.getRealImp());
00241   }
00242 
00243   DUNE_DEPRECATED IntersectionIterator(const IntersectionIteratorImp<const GridImp> & i) :
00244     intersection(i) {};
00245 
00246   DUNE_DEPRECATED IntersectionIterator(const IntersectionIterator& i) :
00247     intersection(i.intersection.getRealImp()) {}
00248 
00249   typedef typename remove_const<GridImp>::type mutableGridImp;
00250 protected:
00251   // give the GridDefaultImplementation class access to the realImp 
00252   friend class GridDefaultImplementation<
00253             GridImp::dimension, GridImp::dimensionworld,
00254             typename GridImp::ctype,
00255             typename GridImp::GridFamily> ;
00256 
00258   ImplementationType & getRealImp() { return intersection.getRealImp(); }
00260   const ImplementationType & getRealImp() const { return intersection.getRealImp(); }
00261 
00262 };
00263 
00264 } // namespace Dune
00265 
00266 #include "intersection.hh"
00267 
00268 #endif // DUNE_GRID_INTERSECTIONITERATOR_HH

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].