dune-grid  2.1.1
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 
00085     void compactify () {}
00086 
00087   protected:
00089     EntityImp &entityImp ();
00090 
00092     const EntityImp &entityImp () const;
00093 
00095     const GridImp &grid () const;
00096    
00097   private:
00098     mutable EntityObject entity_;
00099   };
00100 
00101 
00102 
00103   template< int codim, class GridImp >
00104   inline AlbertaGridEntityPointer< codim, GridImp >
00105     ::AlbertaGridEntityPointer ( const GridImp &grid,
00106                                  const ElementInfo &elementInfo,
00107                                  int subEntity )
00108   : entity_( EntityImp( grid, elementInfo, subEntity ) )
00109   {}     
00110 
00111 
00112   template<int codim, class GridImp >
00113   inline AlbertaGridEntityPointer< codim, GridImp >
00114     ::AlbertaGridEntityPointer ( const GridImp &grid )
00115   : entity_( EntityImp( grid ) )
00116   {}
00117 
00118 
00119   template< int codim, class GridImp >
00120   inline AlbertaGridEntityPointer< codim, GridImp >
00121     ::AlbertaGridEntityPointer ( const EntityImp &entity )
00122   : entity_( entity )
00123   {}
00124 
00125 
00126 #if 0
00127   template< int codim, class GridImp >
00128   inline AlbertaGridEntityPointer< codim, GridImp >
00129     ::AlbertaGridEntityPointer ( const This &other )
00130   : entity_( other.entity_ )
00131   {}
00132 #endif
00133 
00134 
00135 #if 0
00136   template<int codim, class GridImp >
00137   inline AlbertaGridEntityPointer< codim, GridImp >::~AlbertaGridEntityPointer ()
00138   {}
00139 #endif
00140 
00141 
00142 #if 0
00143   template< int codim, class GridImp >
00144   inline typename AlbertaGridEntityPointer< codim, GridImp >::This &
00145   AlbertaGridEntityPointer< codim, GridImp >::operator= ( const This &other )
00146   {
00147     entityImp().setEntity( other.entityImp() );
00148     return *this;
00149   }
00150 #endif
00151 
00152 
00153   template<int codim, class GridImp >
00154   inline bool
00155   AlbertaGridEntityPointer< codim, GridImp >::equals ( const This &other ) const
00156   {
00157     return entityImp().equals( other.entityImp() );
00158   }
00159 
00160 
00161   template<int codim, class GridImp >
00162   inline typename AlbertaGridEntityPointer< codim, GridImp >::Entity &
00163   AlbertaGridEntityPointer< codim, GridImp >::dereference () const
00164   {
00165     return entity_;
00166   }
00167 
00168 
00169   template< int codim, class GridImp >
00170   inline int AlbertaGridEntityPointer< codim, GridImp >::level () const
00171   {
00172     return entityImp().level();
00173   }
00174 
00175 
00176   template< int codim, class GridImp >
00177   inline typename AlbertaGridEntityPointer< codim, GridImp >::EntityImp &
00178   AlbertaGridEntityPointer< codim, GridImp >::entityImp ()
00179   {
00180     return GridImp::getRealImplementation( entity_ );
00181   }
00182 
00183 
00184   template< int codim, class GridImp >
00185   inline const typename AlbertaGridEntityPointer< codim, GridImp >::EntityImp &
00186   AlbertaGridEntityPointer< codim, GridImp >::entityImp () const
00187   {
00188     return GridImp::getRealImplementation( entity_ );
00189   }
00190 
00191 
00192   template< int codim, class GridImp >
00193   inline const GridImp &AlbertaGridEntityPointer< codim, GridImp >::grid () const
00194   {
00195     return entityImp().grid();
00196   }
00197 
00198 }
00199 
00200 #endif // #if HAVE_ALBERTA
00201 
00202 #endif // #ifndef DUNE_ALBERTA_ENTITYPOINTER_HH