All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
entitypointer.hh
1 // -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=2 sw=2 sts=2:
3 #ifndef DUNE_POLYHEDRALGRID_ENTITYPOINTER_HH
4 #define DUNE_POLYHEDRALGRID_ENTITYPOINTER_HH
5 
6 //- dune-grid includes
7 #include <dune/grid/common/grid.hh>
8 
9 //- dune-metagrid includes
10 #include <dune/grid/polyhedralgrid/declaration.hh>
11 
12 namespace Dune
13 {
14  // PolyhedralGridEntityPointer
15  // -------------------
16 
17  template< int codim, class Grid >
19  {
21 
22  protected:
23  typedef typename Grid::Traits Traits;
24 
25  public:
27  static const int dimension = Grid::dimension;
29  static const int codimension = codim;
30 
32  typedef typename Traits::template Codim< codimension >::Entity Entity;
33 
34  protected:
35  typedef typename Traits::ExtraData ExtraData;
36 
37  typedef typename Traits::template Codim< codimension > :: EntityImpl EntityImpl;
38 
39  public:
40  PolyhedralGridEntityPointer ( ExtraData data )
41  : entity_( EntityImpl( data ) )
42  {}
43 
44  explicit PolyhedralGridEntityPointer ( const EntityImpl &entity )
45  : entity_( EntityImpl( entity ) )
46  {}
47 
48  PolyhedralGridEntityPointer ( const This &other )
49  : entity_( EntityImpl( other.entityImpl() ) )
50  {}
51 
52  const This &operator= ( const This &other )
53  {
54  entityImpl() = other.entityImpl();
55  return *this;
56  }
57 
59  bool equals ( const This &other ) const
60  {
61  return entityImpl().equals( other.entityImpl() );
62  }
63 
65  Entity& dereference () const
66  {
67  return entity_;
68  }
69 
70  operator const Entity& () const { return entity_; }
71  operator Entity& () { return entity_; }
72 
74  int level () const { return entity_.level(); }
75 
76  protected:
77  EntityImpl &entityImpl () const
78  {
79  return Grid::getRealImplementation( entity_ );
80  }
81 
82  ExtraData data () const { return entityImpl().data(); }
83 
84  protected:
85  mutable Entity entity_;
86  };
87 
88 } // namespace Dune
89 
90 #endif // #ifndef DUNE_POLYHEDRALGRID_ENTITYPOINTER_HH
Definition: entitypointer.hh:18
static const int dimension
grid dimension
Definition: entitypointer.hh:27
static const int codimension
world dimension
Definition: entitypointer.hh:29
bool equals(const This &other) const
check for equality
Definition: entitypointer.hh:59
int level() const
obtain level
Definition: entitypointer.hh:74
Entity & dereference() const
dereference entity
Definition: entitypointer.hh:65
Traits::template Codim< codimension >::Entity Entity
type of entity
Definition: entitypointer.hh:32