entitypointer.hh
Go to the documentation of this file.
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
11
12namespace 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:
41 : entity_( EntityImpl( data ) )
42 {}
43
44 explicit PolyhedralGridEntityPointer ( const EntityImpl &entity )
45 : entity_( EntityImpl( entity ) )
46 {}
47
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
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:
78 {
79 return entity_.impl();
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:19
Grid::Traits Traits
Definition: entitypointer.hh:23
Entity entity_
Definition: entitypointer.hh:85
Traits::template Codim< codimension >::EntityImpl EntityImpl
Definition: entitypointer.hh:37
PolyhedralGridEntityPointer(const EntityImpl &entity)
Definition: entitypointer.hh:44
EntityImpl & entityImpl() const
Definition: entitypointer.hh:77
const This & operator=(const This &other)
Definition: entitypointer.hh:52
PolyhedralGridEntityPointer(ExtraData data)
Definition: entitypointer.hh:40
bool equals(const This &other) const
check for equality
Definition: entitypointer.hh:59
PolyhedralGridEntityPointer(const This &other)
Definition: entitypointer.hh:48
int level() const
obtain level
Definition: entitypointer.hh:74
static const int codimension
world dimension
Definition: entitypointer.hh:29
ExtraData data() const
Definition: entitypointer.hh:82
Entity & dereference() const
dereference entity
Definition: entitypointer.hh:65
Traits::ExtraData ExtraData
Definition: entitypointer.hh:35
Traits::template Codim< codimension >::Entity Entity
type of entity
Definition: entitypointer.hh:32
static const int dimension
grid dimension
Definition: entitypointer.hh:27
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10