dune-grid  2.2.0
idset.hh
Go to the documentation of this file.
1 #ifndef DUNE_GEOGRID_IDSET_HH
2 #define DUNE_GEOGRID_IDSET_HH
3 
5 
6 namespace Dune
7 {
8 
9  namespace GeoGrid
10  {
11 
12  // IdSet
13  // -----
14 
15  template< class Grid, class HostIdSet >
16  class IdSet
17  : public Dune::IdSet< Grid, IdSet< Grid, HostIdSet >, typename HostIdSet::IdType >
18  {
21 
22  typedef typename remove_const< Grid >::type::Traits Traits;
23 
24  public:
25  typedef typename HostIdSet::IdType IdType;
26 
27  using Base::subId;
28 
29  IdSet ()
30  : hostIdSet_( 0 )
31  {}
32 
33  explicit IdSet ( const HostIdSet &hostIdSet )
34  : hostIdSet_( &hostIdSet )
35  {}
36 
37  IdSet ( const This &other )
38  : hostIdSet_( other.hostIdSet_ )
39  {}
40 
41  const This &operator= ( const This &other )
42  {
43  hostIdSet_ = other.hostIdSet_;
44  return *this;
45  }
46 
47  template< int codim >
48  IdType id ( const typename Traits::template Codim< codim >::Entity &entity ) const
49  {
50  return Grid::getRealImplementation( entity ).id( hostIdSet() );
51  }
52 
53  template< class Entity >
54  IdType id ( const Entity &entity ) const
55  {
56  return id< Entity::codimension >( entity );
57  }
58 
59  IdType subId ( const typename Traits::template Codim< 0 >::Entity &entity, int i, unsigned int codim ) const
60  {
61  return hostIdSet().subId( Grid::template getHostEntity< 0 >( entity ), i, codim );
62  }
63 
64  operator bool () const { return bool( hostIdSet_ ); }
65 
66  private:
67  const HostIdSet &hostIdSet () const
68  {
69  assert( *this );
70  return *hostIdSet_;
71  }
72 
73  const HostIdSet *hostIdSet_;
74  };
75 
76  } // namespace GeoGrid
77 
78 } // namespace Dune
79 
80 #endif // #ifndef DUNE_GEOGRID_IDSET_HH