dune-grid  2.2.0
albertagrid/entitypointer.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ALBERTA_ENTITYPOINTER_HH
00002 #define DUNE_ALBERTA_ENTITYPOINTER_HH
00003 
00004 #include <dune/grid/common/entitypointer.hh>
00005 
00006 #include <dune/grid/albertagrid/elementinfo.hh>
00007 
00008 #if HAVE_ALBERTA
00009 
00010 namespace Dune
00011 {
00012 
00013   // External Forward Declarations
00014   // -----------------------------
00015 
00016   template< int dim, int dimworld >
00017   class AlbertaGrid;
00018 
00019 
00020 
00025   template< int codim, class GridImp >
00026   class AlbertaGridEntityPointer
00027   {
00028     typedef AlbertaGridEntityPointer< codim, GridImp > This;
00029 
00030     friend class AlbertaGrid< GridImp::dimension, GridImp::dimensionworld >;
00031 
00032   public:
00033     static const int dimension = GridImp::dimension;
00034     static const int codimension = codim;
00035     static const int mydimension = dimension - codimension;
00036     static const int dimensionworld = GridImp::dimensionworld;
00037 
00038     typedef typename GridImp::template Codim< codimension >::Entity Entity;
00039 
00040   protected:
00041     typedef MakeableInterfaceObject< Entity > EntityObject;
00042     typedef typename EntityObject::ImplementationType EntityImp;
00043 
00044   public:
00045     typedef AlbertaGridEntityPointer< codimension, GridImp > EntityPointerImp;
00046 
00047     typedef typename EntityImp::ElementInfo ElementInfo;
00048 
00050     AlbertaGridEntityPointer ( const GridImp &grid, 
00051                                const ElementInfo &elementInfo,
00052                                int subEntity );
00053 
00055     AlbertaGridEntityPointer ( const GridImp &grid );
00056 
00058     AlbertaGridEntityPointer ( const EntityImp &entity );
00059 
00060 #if 0
00061 
00062     AlbertaGridEntityPointer ( const This &other );
00063 #endif
00064 
00065 #if 0
00066 
00067     ~AlbertaGridEntityPointer();
00068 #endif
00069 
00070 #if 0
00071 
00072     This &operator= ( const This &other );
00073 #endif
00074 
00076     bool equals ( const This &other ) const;
00077 
00079     Entity &dereference () const;
00080 
00082     int level () const;
00083 
00084   protected:
00086     EntityImp &entityImp ();
00087 
00089     const EntityImp &entityImp () const;
00090 
00092     const GridImp &grid () const;
00093    
00094   private:
00095     mutable EntityObject entity_;
00096   };
00097 
00098 
00099 
00100   template< int codim, class GridImp >
00101   inline AlbertaGridEntityPointer< codim, GridImp >
00102     ::AlbertaGridEntityPointer ( const GridImp &grid,
00103                                  const ElementInfo &elementInfo,
00104                                  int subEntity )
00105   : entity_( EntityImp( grid, elementInfo, subEntity ) )
00106   {}     
00107 
00108 
00109   template<int codim, class GridImp >
00110   inline AlbertaGridEntityPointer< codim, GridImp >
00111     ::AlbertaGridEntityPointer ( const GridImp &grid )
00112   : entity_( EntityImp( grid ) )
00113   {}
00114 
00115 
00116   template< int codim, class GridImp >
00117   inline AlbertaGridEntityPointer< codim, GridImp >
00118     ::AlbertaGridEntityPointer ( const EntityImp &entity )
00119   : entity_( entity )
00120   {}
00121 
00122 
00123 #if 0
00124   template< int codim, class GridImp >
00125   inline AlbertaGridEntityPointer< codim, GridImp >
00126     ::AlbertaGridEntityPointer ( const This &other )
00127   : entity_( other.entity_ )
00128   {}
00129 #endif
00130 
00131 
00132 #if 0
00133   template<int codim, class GridImp >
00134   inline AlbertaGridEntityPointer< codim, GridImp >::~AlbertaGridEntityPointer ()
00135   {}
00136 #endif
00137 
00138 
00139 #if 0
00140   template< int codim, class GridImp >
00141   inline typename AlbertaGridEntityPointer< codim, GridImp >::This &
00142   AlbertaGridEntityPointer< codim, GridImp >::operator= ( const This &other )
00143   {
00144     entityImp().setEntity( other.entityImp() );
00145     return *this;
00146   }
00147 #endif
00148 
00149 
00150   template<int codim, class GridImp >
00151   inline bool
00152   AlbertaGridEntityPointer< codim, GridImp >::equals ( const This &other ) const
00153   {
00154     return entityImp().equals( other.entityImp() );
00155   }
00156 
00157 
00158   template<int codim, class GridImp >
00159   inline typename AlbertaGridEntityPointer< codim, GridImp >::Entity &
00160   AlbertaGridEntityPointer< codim, GridImp >::dereference () const
00161   {
00162     return entity_;
00163   }
00164 
00165 
00166   template< int codim, class GridImp >
00167   inline int AlbertaGridEntityPointer< codim, GridImp >::level () const
00168   {
00169     return entityImp().level();
00170   }
00171 
00172 
00173   template< int codim, class GridImp >
00174   inline typename AlbertaGridEntityPointer< codim, GridImp >::EntityImp &
00175   AlbertaGridEntityPointer< codim, GridImp >::entityImp ()
00176   {
00177     return GridImp::getRealImplementation( entity_ );
00178   }
00179 
00180 
00181   template< int codim, class GridImp >
00182   inline const typename AlbertaGridEntityPointer< codim, GridImp >::EntityImp &
00183   AlbertaGridEntityPointer< codim, GridImp >::entityImp () const
00184   {
00185     return GridImp::getRealImplementation( entity_ );
00186   }
00187 
00188 
00189   template< int codim, class GridImp >
00190   inline const GridImp &AlbertaGridEntityPointer< codim, GridImp >::grid () const
00191   {
00192     return entityImp().grid();
00193   }
00194 
00195 }
00196 
00197 #endif // #if HAVE_ALBERTA
00198 
00199 #endif // #ifndef DUNE_ALBERTA_ENTITYPOINTER_HH