3#ifndef DUNE_GEOMETRY_TOPOLOGYFACTORY_HH 
    4#define DUNE_GEOMETRY_TOPOLOGYFACTORY_HH 
   11#include <dune/geometry/genericgeometry/topologytypes.hh> 
   35  template <
class Traits>
 
   39    static const unsigned int dimension = Traits::dimension;
 
   40    typedef typename Traits::Key Key;
 
   41    typedef typename Traits::Object Object;
 
   42    typedef typename Traits::Factory Factory;
 
   48      GenericGeometry::IfTopology< Maker, dimension >::apply( 
gt.id(), key, 
object );
 
   52    template <
class Topology>
 
   53    static Object *
create(
const Key &key)
 
   55      return Factory::template createObject<Topology> ( key );
 
   64    template< 
class Topology >
 
   67      static void apply ( 
const Key &key, Object *&
object )
 
   69        object = create<Topology>( key );
 
   79  template <
class Factory>
 
   82    static const unsigned int dimension = Factory::dimension;
 
   83    typedef typename Factory::Key Key;
 
   84    typedef const typename Factory::Object Object;
 
   89      assert( 
gt.id() < numTopologies );
 
   90      return instance().getObject( 
gt, key );
 
   93    template< 
class Topology >
 
   94    static Object *
create ( 
const Key &key )
 
   96      static_assert((Topology::dimension == dimension),
 
   97                    "Topology with incompatible dimension used");
 
   98      return instance().template getObject< Topology >( key );
 
  110    static const unsigned int numTopologies = (1 << dimension);
 
  111    typedef std::array< Object *, numTopologies > Array;
 
  112    typedef std::map< Key, Array > Storage;
 
  114    TopologySingletonFactory ()
 
  116    ~TopologySingletonFactory ()
 
  118      const typename Storage::iterator end = storage_.end();
 
  119      for( 
typename Storage::iterator it = storage_.begin(); it != end; ++it )
 
  121        for( 
unsigned int topologyId = 0; topologyId < numTopologies; ++topologyId )
 
  123          Object *&
object = it->second[ topologyId ];
 
  125            Factory::release( 
object );
 
  131    Object *&find( 
const unsigned int topologyId, 
const Key &key )
 
  133      typename Storage::iterator it = storage_.find( key );
 
  134      if( it == storage_.end() )
 
  135        it = storage_.insert( std::make_pair( key, fill_array<Object*, numTopologies>( 
nullptr ) ) ).first;
 
  136      return it->second[ topologyId ];
 
  141      Object *&
object = find( 
gt.id(), key );
 
  143        object = Factory::create( 
gt, key );
 
  147    template< 
class Topology >
 
  148    Object *getObject ( 
const Key &key )
 
  150      Object *&
object = find(Topology::id,key);
 
  152        object = Factory::template create< Topology >( key );
 
Fallback implementation of the std::array class (a static array)
 
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
 
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:132
 
Dune namespace.
Definition: alignment.hh:10
 
Fallback implementation of the nullptr object in C++0x.
 
Provide a factory over the generic topologies.
Definition: topologyfactory.hh:37
 
static Object * create(const Dune::GeometryType >, const Key &key)
dynamically create objects
Definition: topologyfactory.hh:45
 
static Object * create(const Key &key)
statically create objects
Definition: topologyfactory.hh:53
 
static void release(Object *object)
release the object returned by the create methods
Definition: topologyfactory.hh:58
 
A wrapper for a TopologyFactory providing singleton storage. Same usage as TopologyFactory but with e...
Definition: topologyfactory.hh:81
 
static Object * create(const Dune::GeometryType >, const Key &key)
dynamically create objects
Definition: topologyfactory.hh:87
 
static void release(Object *object)
release the object returned by the create methods
Definition: topologyfactory.hh:101
 
static Object * create(const Key &key)
statically create objects
Definition: topologyfactory.hh:94
 
A unique label for each type of element that can occur in a grid.