1 #ifndef DUNE_FEM_OBJECTSTACK_HH 2 #define DUNE_FEM_OBJECTSTACK_HH 13 template<
class ObjectFactoryImp >
16 template<
class ObjectFactoryImp >
20 template<
class ObjectFactoryImp >
25 typedef typename ObjectFactoryImp :: ObjectType
ObjectType;
29 template<
class ObjectFactoryImp >
42 template<
class,
class >
43 friend class Conversion;
51 typedef typename ObjectFactoryType :: ObjectType
ObjectType;
67 object_( stack_.factory().newObject() )
83 ThisType &operator= (
const ThisType & );
86 inline operator const ObjectType& ()
const 91 inline operator ObjectType& ()
117 template<
class ObjectFactoryImp >
149 : factory_( factory ),
150 stackEntries_( StackEntryPtrType(0) )
165 const size_t threadSize = stackEntries_.
size();
166 for(
size_t i=0; i<threadSize; ++i )
168 StackEntryPtrType& stackEntry = stackEntries_[ i ];
169 while ( stackEntry != 0 )
171 StackEntryType *obj = stackEntry;
172 stackEntry = obj->
next_;
180 ThisType &operator= (
const ThisType & );
186 return PointerType( pop() );
190 inline const ObjectFactoryType &
factory()
const 196 inline void push ( StackEntryType *obj )
199 push( obj, *stackEntries_ );
203 inline StackEntryType *
pop ()
206 return pop( *stackEntries_ );
211 inline void push ( StackEntryType *obj, StackEntryPtrType& stackEntry )
213 obj->
next_ = stackEntry;
218 inline StackEntryType *pop ( StackEntryPtrType& stackEntry )
220 StackEntryType *ptr = stackEntry;
222 stackEntry = stackEntry->
next_;
224 ptr =
new StackEntryType( *
this );
233 #endif // #ifndef DUNE_FEM_OBJECTSTACK_HH default implementation of ReferenceCounterInterface
Definition: referencecounter.hh:154
ObjectStackEntry< ObjectFactoryImp > ReferenceCounterType
Definition: objectstack.hh:23
ObjectFactoryType::ObjectType ObjectType
type of the stored objects
Definition: objectstack.hh:129
void deleteObject()
Definition: objectstack.hh:96
ObjectType *const object_
Definition: objectstack.hh:58
ObjectStackEntryTraits< ObjectFactoryType > Traits
Definition: objectstack.hh:36
ObjectStackEntry(ObjectStackType &stack)
Definition: objectstack.hh:64
ObjectStackType & stack_
Definition: objectstack.hh:55
ThisType * next_
Definition: objectstack.hh:61
ObjectFactoryType::ObjectType ObjectType
Definition: objectstack.hh:51
Definition: objectstack.hh:14
ObjectStack(const ObjectFactoryType &factory)
constructor
Definition: objectstack.hh:148
ObjectStackEntry< ObjectFactoryType > StackEntryType
type of the storage objects
Definition: objectstack.hh:132
Definition: coordinate.hh:4
models a pointer to a reference countable object
Definition: referencecounter.hh:231
const ObjectFactoryType & factory_
Definition: objectstack.hh:138
ObjectPointer< StackEntryType > PointerType
type of object pointers
Definition: objectstack.hh:135
~ObjectStack()
delete all objects on stack
Definition: objectstack.hh:160
StackEntryType * StackEntryPtrType
Definition: objectstack.hh:141
void push(StackEntryType *obj)
Definition: objectstack.hh:196
Definition: objectstack.hh:21
size_t size() const
return number of threads
Definition: threadsafevalue.hh:47
ThreadSafeValuesType stackEntries_
Definition: objectstack.hh:145
~ObjectStackEntry()
Definition: objectstack.hh:76
const ObjectType & getObject() const
Definition: objectstack.hh:101
StackEntryType * pop()
Definition: objectstack.hh:203
ObjectType & getObject()
Definition: objectstack.hh:106
PointerType getObject()
get an object pointer to a storage object
Definition: objectstack.hh:184
static bool singleThreadMode()
returns true if program is operating on one thread currently
Definition: threadmanager.hh:217
ObjectStack< ObjectFactoryType > ObjectStackType
Definition: objectstack.hh:48
const ObjectFactoryType & factory() const
Definition: objectstack.hh:190
ObjectFactoryImp::ObjectType ObjectType
Definition: objectstack.hh:25
ThreadSafeValue< StackEntryPtrType > ThreadSafeValuesType
Definition: objectstack.hh:142
ObjectFactoryImp ObjectFactoryType
Definition: objectstack.hh:34
Definition: objectstack.hh:17