dune-grid  2.2.1
persistentcontainerwrapper.hh
Go to the documentation of this file.
1 #ifndef DUNE_PERSISTENTCONTAINERWRAPPER_HH
2 #define DUNE_PERSISTENTCONTAINERWRAPPER_HH
3 
6 
7 namespace Dune
8 {
9 
10  // PersistentContainerWrapper
11  // --------------------------
12 
13  template< class G, class T, class Allocator >
15  {
17 
18  typedef Dune::HostGridAccess< G > HostGridAccess;
19 
20  typedef typename HostGridAccess::HostGrid HostGrid;
22 
23  public:
24  typedef G Grid;
25  typedef T Data;
26 
29 
30  PersistentContainerWrapper ( const Grid &grid, const int codim, const Allocator &allocator = Allocator() )
31  : hostContainer_( HostGridAccess::hostGrid( grid ), codim, allocator )
32  {}
33 
34  template< class Entity >
35  Data &operator[] ( const Entity &entity )
36  {
37  return hostContainer_[ HostGridAccess::hostEntity( entity ) ];
38  }
39 
40  template< class Entity >
41  const Data &operator[] ( const Entity &entity ) const
42  {
43  return hostContainer_[ HostGridAccess::hostEntity( entity ) ];
44  }
45 
46  template< class Entity >
47  Data &operator() ( const Entity &entity, const int subEntity )
48  {
49  return hostContainer_( HostGridAccess::hostEntity( entity ), subEntity );
50  }
51 
52  template< class Entity >
53  const Data &operator() ( const Entity &entity, const int subEntity ) const
54  {
55  return hostContainer_( HostGridAccess::hostEntity( entity ), subEntity );
56  }
57 
58  Iterator begin () { return hostContainer_.begin(); }
59  ConstIterator begin () const { return hostContainer_.begin(); }
60 
61  Iterator end () { return hostContainer_.end(); }
62  ConstIterator end () const { return hostContainer_.end(); }
63 
64  size_t size () const { return hostContainer_.size(); }
65 
66  void clear () { hostContainer_.clear(); }
67  void reserve () { hostContainer_.reserve(); }
68  void update () { hostContainer_.update(); }
69 
70  private:
71  PersistentContainerHostGrid hostContainer_ ;
72  };
73 
74 } // namespace Dune
75 
76 #endif // #ifndef DUNE_PERSISTENTCONTAINERWRAPPER_HH