Dune::EntityPointer< GridImp, IteratorImp > Class Template Reference
[EntityPointer and Iterators]
#include <entitypointer.hh>
Detailed Description
template<class GridImp, class IteratorImp>
class Dune::EntityPointer< GridImp, IteratorImp >
Wrapper class for pointers to entities.
Template parameters are:
GridImp
Type that is a model of Dune::GridIteratorImp
Class template that is a model of Dune::EntityPointer
Engine Concept
The EntityPointer class template wraps an object of type IteratorImp and forwards all member function calls to corresponding members of this class. In that sense EntityPointer defines the interface and IteratorImp supplies the implementation.
Relation of EntityPointer and Iterators
The EntityPointer can be used like a static iterator. It points to a Dune::Entity and can be dereferenced, compared and it knows the Entity's level.
You should be able to initialize and interpret every Dune::XxxIterator that iterates over entities as a Dune::EntityPointer. Therefore we need an inheritance hierarchy of the Iterator wrappers:
class Dune::EntityPointer<...>; class Dune::LevelIterator<...> : public Dune::EntityPointer<...>; class Dune::HierarchicIterator<...> : public Dune::EntityPointer<...>; class Dune::LeafIterator<...> : public Dune::EntityPointer<...>;
This hierarchy must be mimicked in the implementation (i.e. SGrid):
class SEntityPointer<...> : public Dune::EntityPointerDefault<..., SEntityPointer>; class SLevelIterator<...> : public SEntityPointer <...>, public Dune::LevelIteratorDefault <..., SLevelIterator>; class SHierarchicIterator<...> : public SEntityPointer <...>, public Dune::HierarchicIteratorDefault <..., SHierarchicIterator>; ...
This leads to a hierarchy where Dune::LevelIterator<..., SLevelIterator> inherits Dune::EntityPointer<..., SLevelIterator> and Dune::HierarchicIterator<..., SHierarchicIterator> inherits Dune::EntityPointer<..., SHierarchicIterator>. And virtualy all Dune::EntityPointer<..., SXxxIterator> are descendents of Dune::EntityPointer<..., SEntityPointer>.
Now you can compare Dune::LevelIterator with Dune::EntityPointer and Dune::LeafIterator with Dune::HierarchicIterator. And you can assign Dune::EntityPointer from any Dune::XxxIterator class. Even more, you can cast an Iterator refence to a reference pointing to Dune::EntityPointer.
The compiler takes care that you only assign/compare Iterators from the same Grid.
The downside (or advantage) of this inheritance is that you can not use different comparison operators and different dereference oprators for the different Iterators in one Grid. On the first sight it is a downside because one might consider it a good idea to have special treatment for different iterators. On the other hand it's very confusing for the user if different Iterators show different behavior in the same situation. So now they are forced to show the same behavior.
Public Types | |
enum | { codim = IteratorImp::codimension } |
typedef IteratorImp | ImplementationType |
type of real implementation | |
typedef Dune::EnableIfInterOperable < typename IteratorImp::base, IteratorImp, typename IteratorImp::base >::type | base |
autocheck wether imp is convertable into imp::base | |
typedef IteratorImp::Entity | Entity |
The Entity that this EntityPointer can point to. | |
Public Member Functions | |
Constructor & conversion | |
template<class ItImp> | |
EntityPointer (const EntityPointer< GridImp, ItImp > &ep) | |
Templatized copy constructor from arbitrary IteratorImp. This enables that an EntityPointer can be copy-constructed from LevelIterator, LeafIterator and HierarchicIterator (because these are derived from EntityPointer<...> with their corresponding implementation. | |
operator EntityPointer< GridImp, base > & () | |
Cast to EntityPointer with base class of implementation as engine. This conversion ensures assignablity of LevelIterator, LeafIterator and HierarchicIterator to EntityPointer. | |
operator const EntityPointer< GridImp, base > & () const | |
Cast to EntityPointer with const base class of implementation as engine. This conversion ensures assignablity of LevelIterator, LeafIterator and HierarchicIterator to EntityPointer. | |
Dereferencing | |
Entity & | operator* () const |
Dereferencing operator. | |
Entity * | operator-> () const |
Pointer operator. | |
Dereferencing methods | |
bool | operator== (const EntityPointer< GridImp, base > &rhs) const |
Checks for equality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer. | |
bool | operator!= (const EntityPointer< GridImp, base > &rhs) const |
Checks for inequality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer. | |
Query methods | |
int | level () const |
Ask for level of entity. This method is redundant and is only there for efficiency reasons. It allows an implementation to return the level without actually constructing the entity. | |
Implementor interface | |
EntityPointer (const IteratorImp &i) | |
Copy Constructor from an Iterator implementation. | |
bool | equals (const EntityPointer &rhs) const |
Forward equality check to realIterator. | |
Protected Member Functions | |
ImplementationType & | getRealImp () |
return reference to the real implementation | |
const ImplementationType & | getRealImp () const |
return reference to the real implementation |
Member Enumeration Documentation
anonymous enum |
- Enumerator:
-
codim The codimension of this EntityPointer.
Constructor & Destructor Documentation
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer | ( | const IteratorImp & | i | ) | [inline] |
Copy Constructor from an Iterator implementation.
You can supply LeafIterator, LevelIterator, HierarchicIterator or EntityPointer.
The documentation for this class was generated from the following file: