dune-grid  2.1.1
Public Types | Protected Types | Protected Member Functions | Protected Attributes | Friends
Dune::EntityPointer< GridImp, IteratorImp > Class Template Reference

Wrapper class for pointers to entities. More...

#include <dune/grid/common/entitypointer.hh>

Inheritance diagram for Dune::EntityPointer< GridImp, IteratorImp >:
Inheritance graph

List of all members.

Public Types

enum  { codimension = IteratorImp::codimension }
 codimension of entity pointer More...
enum  { codim = IteratorImp::codimension }
typedef IteratorImp ImplementationType
 type of real implementation
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.
 EntityPointer (const Entity &entity)
 Templatized constructor from type of entity that this entity pointer points to. This constructor can be used to create an entity pointer from an entity in order to store an entity. The implementation of EntityPointer has to have a constructor taking a Dune::Entity.
 EntityPointer (const typename Entity::ImplementationType &entityImp)
 Constructor from type of entity implementation that this entity pointer points to. This constructor is only used in the EntityDefaultImplementation to implement the method seed() by default when the type of EntitySeed and EntityPointer coniside.
template<class ItImp >
EntityPointeroperator= (const EntityPointer< GridImp, ItImp > &ep)
 operator const EntityPointer< GridImp, base > & () const
 Cast to EntityPointer with const base class of implementation as engine.
void compactify ()
Dereferencing
Entityoperator* () const
 Dereferencing operator.
Entityoperator-> () const
 Pointer operator.
Compare methods
template<class ItImp >
bool operator== (const EntityPointer< GridImp, ItImp > &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.
template<class ItImp >
bool operator!= (const EntityPointer< GridImp, ItImp > &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.
template<class ItImp >
bool equals (const EntityPointer< GridImp, ItImp > &rhs) const
 Forward equality check to realIterator.

Protected Types

typedef
Dune::EnableIfInterOperable
< typename
IteratorImp::EntityPointerImp,
IteratorImp, typename
IteratorImp::EntityPointerImp >
::type 
base

Protected Member Functions

ImplementationTypegetRealImp ()
 return reference to the real implementation
const ImplementationTypegetRealImp () const
 return reference to the real implementation

Protected Attributes

IteratorImp realIterator

Friends

class Dune::GenericLeafIterator< GridImp >
class EntityPointer
class GridDefaultImplementation< GridImp::dimension, GridImp::dimensionworld, typename GridImp::ctype, typename GridImp::GridFamily >

Detailed Description

template<class GridImp, class IteratorImp>
class Dune::EntityPointer< GridImp, IteratorImp >

Wrapper class for pointers to entities.

Template parameters are:

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::EntityIterator as a Dune::EntityPointer. Therefore we need an inheritance hierarchy of the Iterator wrappers:

    class Dune::EntityPointer< Grid, IteratorImp >;

    class Dune::EntityIterator< codim, Grid, IteratorImp >
    : public Dune::EntityPointer< Grid, IteratorImp >;

This hierarchy must be mimicked in the implementation (i.e. SGrid):

    class SEntityPointer<...>;

    class SLevelIterator<...> :
       public SEntityPointer <...>;

    class SHierarchicIterator<...> :
       public SEntityPointer <...>;
       
    ...

Please note that dereference(...), equals(...) and level() are only implemented in SEntityPointer -- SLevelIterator inherits these methods. And it is not possible to specialize these, because EntityPointer always uses the base class.

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.


Member Typedef Documentation

template<class GridImp, class IteratorImp>
typedef Dune::EnableIfInterOperable<typename IteratorImp::EntityPointerImp,IteratorImp, typename IteratorImp::EntityPointerImp>::type Dune::EntityPointer< GridImp, IteratorImp >::base [protected]
template<class GridImp, class IteratorImp>
typedef IteratorImp::Entity Dune::EntityPointer< GridImp, IteratorImp >::Entity
template<class GridImp, class IteratorImp>
typedef IteratorImp Dune::EntityPointer< GridImp, IteratorImp >::ImplementationType

type of real implementation


Member Enumeration Documentation

template<class GridImp, class IteratorImp>
anonymous enum

codimension of entity pointer

Enumerator:
codimension 
template<class GridImp, class IteratorImp>
anonymous enum
Enumerator:
codim 

The codimension of this EntityPointer.


Constructor & Destructor Documentation

template<class GridImp, class IteratorImp>
template<class ItImp >
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const EntityPointer< GridImp, ItImp > &  ep) [inline, explicit]

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.

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const Entity entity) [inline]

Templatized constructor from type of entity that this entity pointer points to. This constructor can be used to create an entity pointer from an entity in order to store an entity. The implementation of EntityPointer has to have a constructor taking a Dune::Entity.

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const typename Entity::ImplementationType entityImp) [inline]

Constructor from type of entity implementation that this entity pointer points to. This constructor is only used in the EntityDefaultImplementation to implement the method seed() by default when the type of EntitySeed and EntityPointer coniside.

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const IteratorImp &  i) [inline]

Copy Constructor from an Iterator implementation.

You can supply LeafIterator, LevelIterator, HierarchicIterator or EntityPointer.


Member Function Documentation

template<class GridImp, class IteratorImp>
void Dune::EntityPointer< GridImp, IteratorImp >::compactify ( ) [inline]
Deprecated:
Reduce the entity pointers used memory to a minimum necessary to store all needed information.

Use EntitySeed to store entity information.

Deprecated:
template<class GridImp, class IteratorImp>
template<class ItImp >
bool Dune::EntityPointer< GridImp, IteratorImp >::equals ( const EntityPointer< GridImp, ItImp > &  rhs) const [inline]
template<class GridImp, class IteratorImp>
ImplementationType& Dune::EntityPointer< GridImp, IteratorImp >::getRealImp ( ) [inline, protected]

return reference to the real implementation

template<class GridImp, class IteratorImp>
const ImplementationType& Dune::EntityPointer< GridImp, IteratorImp >::getRealImp ( ) const [inline, protected]

return reference to the real implementation

template<class GridImp, class IteratorImp>
int Dune::EntityPointer< GridImp, IteratorImp >::level ( ) const [inline]

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.

Referenced by Dune::GeoGrid::EntityPointer< Traits, true >::equals(), and Dune::GeoGrid::EntityPointer< Traits, false >::level().

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::operator const EntityPointer< GridImp, base > & ( ) const [inline]

Cast to EntityPointer with const base class of implementation as engine.

Note:
This cast is no longer needed to ensure assignability of iterators to EntityPointer.
Deprecated:
template<class GridImp, class IteratorImp>
template<class ItImp >
bool Dune::EntityPointer< GridImp, IteratorImp >::operator!= ( const EntityPointer< GridImp, ItImp > &  rhs) const [inline]

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.

template<class GridImp, class IteratorImp>
Entity& Dune::EntityPointer< GridImp, IteratorImp >::operator* ( ) const [inline]

Dereferencing operator.

template<class GridImp, class IteratorImp>
Entity* Dune::EntityPointer< GridImp, IteratorImp >::operator-> ( ) const [inline]

Pointer operator.

template<class GridImp, class IteratorImp>
template<class ItImp >
EntityPointer& Dune::EntityPointer< GridImp, IteratorImp >::operator= ( const EntityPointer< GridImp, ItImp > &  ep) [inline]
template<class GridImp, class IteratorImp>
template<class ItImp >
bool Dune::EntityPointer< GridImp, IteratorImp >::operator== ( const EntityPointer< GridImp, ItImp > &  rhs) const [inline]

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.


Friends And Related Function Documentation

template<class GridImp, class IteratorImp>
friend class Dune::GenericLeafIterator< GridImp > [friend]
template<class GridImp, class IteratorImp>
friend class EntityPointer [friend]
template<class GridImp, class IteratorImp>
friend class GridDefaultImplementation< GridImp::dimension, GridImp::dimensionworld,typename GridImp::ctype,typename GridImp::GridFamily > [friend]

Member Data Documentation

template<class GridImp, class IteratorImp>
IteratorImp Dune::EntityPointer< GridImp, IteratorImp >::realIterator [protected]

The documentation for this class was generated from the following file: