dune-grid
2.2beta1
|
00001 #ifndef DUNE_PERSISTENTCONTAINERWRAPPER_HH 00002 #define DUNE_PERSISTENTCONTAINERWRAPPER_HH 00003 00004 #include <dune/grid/utility/hostgridaccess.hh> 00005 #include <dune/grid/utility/persistentcontainer.hh> 00006 00007 namespace Dune 00008 { 00009 00010 // PersistentContainerWrapper 00011 // -------------------------- 00012 00013 template< class G, class T, class Allocator > 00014 class PersistentContainerWrapper 00015 { 00016 typedef PersistentContainerWrapper< G, T, Allocator > This; 00017 00018 typedef Dune::HostGridAccess< G > HostGridAccess; 00019 00020 typedef typename HostGridAccess::HostGrid HostGrid; 00021 typedef PersistentContainer< HostGrid, T, Allocator > PersistentContainerHostGrid; 00022 00023 public: 00024 typedef G Grid; 00025 typedef T Data; 00026 00027 typedef typename PersistentContainerHostGrid::Iterator Iterator; 00028 typedef typename PersistentContainerHostGrid::ConstIterator ConstIterator; 00029 00030 PersistentContainerWrapper ( const Grid &grid, const int codim, const Allocator &allocator = Allocator() ) 00031 : hostContainer_( HostGridAccess::hostGrid( grid ), codim, allocator ) 00032 {} 00033 00034 template< class Entity > 00035 Data &operator[] ( const Entity &entity ) 00036 { 00037 return hostContainer_[ HostGridAccess::hostEntity( entity ) ]; 00038 } 00039 00040 template< class Entity > 00041 const Data &operator[] ( const Entity &entity ) const 00042 { 00043 return hostContainer_[ HostGridAccess::hostEntity( entity ) ]; 00044 } 00045 00046 template< class Entity > 00047 Data &operator() ( const Entity &entity, const int subEntity ) 00048 { 00049 return hostContainer_( HostGridAccess::hostEntity( entity ), subEntity ); 00050 } 00051 00052 template< class Entity > 00053 const Data &operator() ( const Entity &entity, const int subEntity ) const 00054 { 00055 return hostContainer_( HostGridAccess::hostEntity( entity ), subEntity ); 00056 } 00057 00058 Iterator begin () { return hostContainer_.begin(); } 00059 ConstIterator begin () const { return hostContainer_.begin(); } 00060 00061 Iterator end () { return hostContainer_.end(); } 00062 ConstIterator end () const { return hostContainer_.end(); } 00063 00064 size_t size () const { return hostContainer_.size(); } 00065 00066 void clear () { hostContainer_.clear(); } 00067 void reserve () { hostContainer_.reserve(); } 00068 void update () { hostContainer_.update(); } 00069 00070 private: 00071 PersistentContainerHostGrid hostContainer_ ; 00072 }; 00073 00074 } // namespace Dune 00075 00076 #endif // #ifndef DUNE_PERSISTENTCONTAINERWRAPPER_HH