dune-grid  2.1.1
backuprestore.hh
Go to the documentation of this file.
00001 #ifndef DUNE_GEOGRID_BACKUPRESTORE_HH
00002 #define DUNE_GEOGRID_BACKUPRESTORE_HH
00003 
00004 #include <dune/grid/utility/grapedataioformattypes.hh>
00005 
00006 #include <dune/grid/geometrygrid/capabilities.hh>
00007 
00008 namespace Dune
00009 {
00010 
00011   namespace GeoGrid
00012   {
00013 
00014     // BackupRestoreFacilities
00015     // -----------------------
00016 
00017     template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities< Grid > ::v >
00018     class BackupRestoreFacilities
00019     {};
00020 
00021     template< class Grid >
00022     class BackupRestoreFacilities< Grid, true >
00023     {
00024       typedef BackupRestoreFacilities< Grid, true > This;
00025 
00026     protected:
00027       BackupRestoreFacilities ()
00028       {}
00029 
00030     private:
00031       BackupRestoreFacilities ( const This & );
00032       This &operator= ( const This & );
00033 
00034     public:
00035       template< GrapeIOFileFormatType type >
00036       bool writeGrid ( const std::string &filename, double time ) const
00037       {
00038         return asImp().hostGrid().template writeGrid< type >( filename, time );
00039       }
00040 
00041       template< GrapeIOFileFormatType type >
00042       bool readGrid ( const std::string &filename, double &time )
00043       {
00044         const bool success
00045           = asImp().hostGrid().template readGrid< type >( filename, time );
00046         asImp().update();
00047         return success;
00048       }
00049 
00050     protected:
00051       const Grid &asImp () const
00052       {
00053         return static_cast< const Grid & >( *this );
00054       }
00055 
00056       Grid &asImp ()
00057       {
00058         return static_cast< Grid & >( *this );
00059       }
00060     };
00061 
00062   }
00063 
00064 }
00065 
00066 #endif // #ifndef DUNE_GEOGRID_BACKUPRESTORE_HH