1 #ifndef DUNE_GEOMETRY_TOPOLOGYFACTORY_HH
2 #define DUNE_GEOMETRY_TOPOLOGYFACTORY_HH
7 #include <dune/common/fvector.hh>
32 template <
class Traits>
36 static const unsigned int dimension = Traits::dimension;
37 typedef typename Traits::Key
Key;
38 typedef typename Traits::Object
Object;
59 template <
class Topology>
62 return Factory::template createObject<Topology> ( key );
71 template<
class Topology >
74 static void apply (
const Key &key,
Object *&
object )
76 object = create<Topology>( key );
86 template <
class Factory>
89 static const unsigned int dimension = Factory::dimension;
90 typedef typename Factory::Key
Key;
91 typedef const typename Factory::Object
Object;
101 assert( gt.
id() < numTopologies );
102 return instance().getObject( gt, key );
105 template<
class Topology >
108 dune_static_assert( (Topology::dimension ==
dimension),
109 "Topology with incompatible dimension used" );
110 return instance().template getObject< Topology >( key );
122 static const unsigned int numTopologies = (1 <<
dimension);
123 typedef FieldVector< Object *, numTopologies > Array;
124 typedef std::map< Key, Array > Storage;
126 TopologySingletonFactory ()
128 ~TopologySingletonFactory ()
130 const typename Storage::iterator end = storage_.end();
131 for(
typename Storage::iterator it = storage_.begin(); it != end; ++it )
137 Factory::release(
object );
145 typename Storage::iterator it = storage_.find( key );
146 if( it == storage_.end() )
147 it = storage_.insert( std::make_pair( key, Array( 0 ) ) ).first;
153 Object *&
object = find( gt.
id(), key );
155 object = Factory::create( gt, key );
159 template<
class Topology >
162 Object *&
object = find(Topology::id,key);
164 object = Factory::template create< Topology >( key );
172 #endif // #ifndef DUNE_GEOMETRY_TOPOLOGYFACTORY_HH