dune-grid  2.1.1
geometrygrid/entityseed.hh
Go to the documentation of this file.
00001 #ifndef DUNE_GEOGRID_ENTITYSEED_HH
00002 #define DUNE_GEOGRID_ENTITYSEED_HH
00003 
00004 #include <dune/common/typetraits.hh>
00005 
00006 #include <dune/grid/geometrygrid/capabilities.hh>
00007 
00008 namespace Dune
00009 {
00010 
00011   namespace GeoGrid
00012   {
00013 
00014     // Internal Forward Declarations
00015     // -----------------------------
00016 
00017     template< int codim, class Grid, bool fake = !(Capabilities::hasHostEntity< Grid, codim >::v) >
00018     class EntitySeed;
00019 
00020 
00021 
00022     // EntitySeed (real)
00023     // -----------------
00024 
00025     template< int codim, class Grd >
00026     class EntitySeed< codim, Grd, false >
00027     {
00028       typedef typename remove_const< Grd >::type::Traits Traits;
00029 
00030     public:
00031       static const int codimension = codim;
00032       static const int dimension = Traits::dimension;
00033       static const int mydimension = dimension - codimension;
00034       static const int dimensionworld = Traits::dimensionworld;
00035 
00036       static const bool fake = false;
00037 
00038       typedef typename Traits::Grid Grid;
00039       typedef typename Traits::template Codim< codim >::Entity Entity;
00040 
00041       typedef typename Traits::HostGrid HostGrid;
00042       typedef typename HostGrid::template Codim< codim >::EntitySeed HostEntitySeed;
00043 
00044       explicit EntitySeed ( const HostEntitySeed &hostEntitySeed )
00045       : hostEntitySeed_( hostEntitySeed )
00046       {}
00047 
00048       const HostEntitySeed &hostEntitySeed () const { return hostEntitySeed_; }
00049 
00050     private:
00051       HostEntitySeed hostEntitySeed_;
00052     };
00053 
00054 
00055 
00056     // EntitySeed (fake)
00057     // -----------------
00058 
00059     template< int codim, class Grd >
00060     class EntitySeed< codim, Grd, true >
00061     {
00062       typedef typename remove_const< Grd >::type::Traits Traits;
00063 
00064     public:
00065       static const int codimension = codim;
00066       static const int dimension = Traits::dimension;
00067       static const int mydimension = dimension - codimension;
00068       static const int dimensionworld = Traits::dimensionworld;
00069 
00070       static const bool fake = true;
00071 
00072       typedef typename Traits::Grid Grid;
00073       typedef typename Traits::template Codim< codim >::Entity Entity;
00074 
00075       typedef typename Traits::HostGrid HostGrid;
00076       typedef typename HostGrid::template Codim< 0 >::EntitySeed HostElementSeed;
00077 
00078       explicit EntitySeed ( const HostElementSeed &hostElementSeed, unsigned int subEntity )
00079       : hostElementSeed_( hostElementSeed ),
00080         subEntity_( subEntity )
00081       {}
00082 
00083       const HostElementSeed &hostElementSeed () const { return hostElementSeed_; }
00084       unsigned int subEntity () const { return subEntity_; }
00085 
00086     private:
00087       HostElementSeed hostElementSeed_;
00088       unsigned int subEntity_;
00089     };
00090 
00091   }
00092 
00093 }
00094 
00095 #endif // #ifndef DUNE_GEOGRID_ENTITYSEED_HH