16 #if !defined(XALAN_OBJECTCACHE_HEADER_GUARD)
17 #define XALAN_OBJECTCACHE_HEADER_GUARD
31 XALAN_CPP_NAMESPACE_BEGIN
35 template<
class ObjectType>
43 typedef ObjectType ThisType;
47 ThisType* theResult = theGuard.
get();
49 new (theResult) ThisType();
58 template<
class ObjectType>
66 typedef ObjectType ThisType;
70 ThisType* theResult = theGuard.
get();
72 new (theResult) ThisType(theManager);
81 template<
class ObjectType>
94 template<
class ObjectType>
102 theInstance->clear();
108 #if defined(XALAN_OBJECT_CACHE_KEEP_BUSY_LIST)
112 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
113 class CreateFunctorType,
114 class DeleteFunctorType,
115 class ResetFunctorType>
132 unsigned int initialListSize = 0) :
133 m_availableList(theManager),
134 m_busyList(theManager)
136 m_availableList.
reserve(initialListSize);
138 m_busyList.reserve(initialListSize);
145 #if !defined(XALAN_NO_STD_NAMESPACE)
150 m_availableList.
begin(),
151 m_availableList.
end(),
160 if (m_availableList.
empty() ==
true)
164 m_busyList.push_back(theNewObject);
170 ObjectType*
const theObject = m_availableList.
back();
172 m_busyList.push_back(theObject);
181 release(ObjectType* theInstance)
183 #if !defined(XALAN_NO_STD_NAMESPACE)
189 const IteratorType i =
195 if (i == m_busyList.end())
214 while (m_busyList.empty() ==
false)
216 ObjectType*
const theInstance = m_busyList.back();
222 m_busyList.pop_back();
256 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
257 class CreateFunctorType,
258 class DeleteFunctorType,
259 class ResetFunctorType>
275 unsigned int initialListSize = 0) :
277 m_availableList(theManager)
279 m_availableList.
reserve(initialListSize);
286 #if !defined(XALAN_NO_STD_NAMESPACE)
291 m_availableList.
begin(),
292 m_availableList.
end(),
301 if (m_availableList.
empty() ==
true)
307 ObjectType*
const theObject = m_availableList.
back();
356 template<
class XalanObjectCacheType>
365 m_cachedObject(theCache.
get())
371 if (m_cachedObject != 0)
373 m_cache.release(m_cachedObject);
380 return m_cachedObject;
400 XalanObjectCacheType& m_cache;
407 template<
class ObjectType>
411 DefaultCacheCreateFunctor<ObjectType>,
412 DeleteFunctor<ObjectType>,
413 DefaultCacheResetFunctor<ObjectType> >
426 unsigned int initialListSize = 0) :
434 template<
class ObjectType>
438 DefaultCacheCreateFunctorMemMgr<ObjectType>,
439 DeleteFunctor<ObjectType>,
440 DefaultCacheResetFunctor<ObjectType> >
453 unsigned int initialListSize = 0) :
461 XALAN_CPP_NAMESPACE_END
XalanObjectCache< ObjectType, DefaultCacheCreateFunctor< ObjectType >, DeleteFunctor< ObjectType >, DefaultCacheResetFunctor< ObjectType > > BaseClassType
Definition: XalanObjectCache.hpp:421
Definition: XalanObjectCache.hpp:265
ObjectType CacheObjectType
Definition: XalanObjectCache.hpp:271
XalanObjectCache< ObjectType, DefaultCacheCreateFunctorMemMgr< ObjectType >, DeleteFunctor< ObjectType >, DefaultCacheResetFunctor< ObjectType > > BaseClassType
Definition: XalanObjectCache.hpp:448
Definition: XalanObjectCache.hpp:95
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
iterator end()
Definition: XalanVector.hpp:701
Definition: XalanObjectCache.hpp:59
XalanMemoryManagerObjectCacheDefault(MemoryManagerType &theManager, unsigned int initialListSize=0)
Definition: XalanObjectCache.hpp:451
value_type * iterator
Definition: XalanVector.hpp:91
XalanObjectCache(MemoryManagerType &theManager, unsigned int initialListSize=0)
Definition: XalanObjectCache.hpp:274
ResetFunctorType m_resetFunctor
Definition: XalanObjectCache.hpp:335
~XalanObjectCache()
Definition: XalanObjectCache.hpp:282
reference back()
Definition: XalanVector.hpp:673
void operator()(ObjectType *) const
Definition: XalanObjectCache.hpp:87
void pop_back()
Definition: XalanVector.hpp:256
bool empty() const
Definition: XalanVector.hpp:636
Definition: XalanObjectCache.hpp:435
Definition: XalanObjectCache.hpp:82
void push_back(const value_type &data)
Definition: XalanVector.hpp:246
XalanVector< ObjectType * > VectorType
Definition: XalanObjectCache.hpp:269
iterator begin()
Definition: XalanVector.hpp:685
CacheObjectType * release()
Definition: XalanObjectCache.hpp:384
ObjectType * operator()(MemoryManagerType &theManager) const
Definition: XalanObjectCache.hpp:41
CacheObjectType * get() const
Definition: XalanObjectCache.hpp:378
~GuardCachedObject()
Definition: XalanObjectCache.hpp:369
void reserve(size_type theSize)
Definition: XalanVector.hpp:644
Definition: XalanObjectCache.hpp:357
Type * get() const
Definition: XalanMemMgrAutoPtr.hpp:164
DeleteFunctorType m_deleteFunctor
Definition: XalanObjectCache.hpp:333
void reset()
Definition: XalanObjectCache.hpp:326
ObjectType * operator()(MemoryManagerType &theManager) const
Definition: XalanObjectCache.hpp:64
Definition: XalanMemMgrAutoPtr.hpp:46
Definition: XalanObjectCache.hpp:36
Definition: XalanObjectCache.hpp:408
CreateFunctorType m_createFunctor
Definition: XalanObjectCache.hpp:331
XalanObjectCacheType::CacheObjectType CacheObjectType
Definition: XalanObjectCache.hpp:361
GuardCachedObject(XalanObjectCacheType &theCache)
Definition: XalanObjectCache.hpp:363
XalanObjectCacheDefault(MemoryManagerType &theManager, unsigned int initialListSize=0)
Definition: XalanObjectCache.hpp:424
bool release(ObjectType *theInstance)
Definition: XalanObjectCache.hpp:316
const MemoryManager * getMemoryManager() const
Definition: XalanVector.hpp:871
void operator()(ObjectType *theInstance) const
Definition: XalanObjectCache.hpp:100