dune-grid  2.7.1
idset.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_GEOGRID_IDSET_HH
4 #define DUNE_GEOGRID_IDSET_HH
5 
7 
8 namespace Dune
9 {
10 
11  namespace GeoGrid
12  {
13 
14  // IdSet
15  // -----
16 
17  template< class Grid, class HostIdSet >
18  class IdSet
19  : public Dune::IdSet< Grid, IdSet< Grid, HostIdSet >, typename HostIdSet::IdType >
20  {
23 
24  typedef typename std::remove_const< Grid >::type::Traits Traits;
25 
26  public:
27  typedef typename HostIdSet::IdType IdType;
28 
29  using Base::subId;
30 
31  IdSet ()
32  : hostIdSet_( 0 )
33  {}
34 
35  explicit IdSet ( const HostIdSet &hostIdSet )
36  : hostIdSet_( &hostIdSet )
37  {}
38 
39  IdSet ( const This &other )
40  : hostIdSet_( other.hostIdSet_ )
41  {}
42 
43  const This &operator= ( const This &other )
44  {
45  hostIdSet_ = other.hostIdSet_;
46  return *this;
47  }
48 
49  template< int codim >
50  IdType id ( const typename Traits::template Codim< codim >::Entity &entity ) const
51  {
52  return entity.impl().id( hostIdSet() );
53  }
54 
55  template< class Entity >
56  IdType id ( const Entity &entity ) const
57  {
58  return id< Entity::codimension >( entity );
59  }
60 
61  IdType subId ( const typename Traits::template Codim< 0 >::Entity &entity, int i, unsigned int codim ) const
62  {
63  return hostIdSet().subId( Grid::template getHostEntity< 0 >( entity ), i, codim );
64  }
65 
66  explicit operator bool () const { return bool( hostIdSet_ ); }
67 
68  private:
69  const HostIdSet &hostIdSet () const
70  {
71  assert( *this );
72  return *hostIdSet_;
73  }
74 
75  const HostIdSet *hostIdSet_;
76  };
77 
78  } // namespace GeoGrid
79 
80 } // namespace Dune
81 
82 #endif // #ifndef DUNE_GEOGRID_IDSET_HH
Provides base classes for index and id sets.
Include standard header files.
Definition: agrid.hh:59
Id Set Interface.
Definition: indexidset.hh:441
IdType subId(const typename std::remove_const< GridImp >::type::Traits::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Get id of subentity i of co-dimension codim of a co-dimension 0 entity.
Definition: indexidset.hh:468
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:32
Definition: idset.hh:20
IdSet()
Definition: idset.hh:31
IdSet(const HostIdSet &hostIdSet)
Definition: idset.hh:35
IdType id(const Entity &entity) const
Definition: idset.hh:56
IdType subId(const typename Traits::template Codim< 0 >::Entity &entity, int i, unsigned int codim) const
Definition: idset.hh:61
IdType id(const typename Traits::template Codim< codim >::Entity &entity) const
Definition: idset.hh:50
IdSet(const This &other)
Definition: idset.hh:39
const This & operator=(const This &other)
Definition: idset.hh:43
HostIdSet::IdType IdType
Definition: idset.hh:27