23#include <osl/diagnose.h>
42 bool bFirstFound =
false;
57 assert(pObj == pNext->
GetPrev());
60 assert(pObj != pOldRealFirst); (void) pOldRealFirst;
66 "Lost FreePositions." );
69#define INCREMENT( nVar ) ++nVar
73#define INCREMENT( nVar )
82 m_pRealFirst( nullptr ),
85 m_nCurMax( nInitSize )
96 , m_nAverageSeekCnt( 0 )
98 , m_nFlushedObjects( 0 )
100 , m_nDecreaseMax( 0 )
116 <<
"; number or reordering (LRU): " <<
m_nToTop
117 <<
"; number of suppressions: " <<
m_nDelete
118 <<
"; number of Gets without Index: " <<
m_nGetSeek
234 else if ( bToTop && pRet !=
m_pFirst )
257 if ( bToTop && pRet && pRet !=
m_pFirst )
273 OSL_ENSURE( !pObj->
IsLocked(),
"SwCache::Delete: object is locked." );
340 OSL_ENSURE( !pNew->
GetPrev() && !pNew->
GetNext(),
"New but not new." );
341 if (!isDuplicateOwnerAllowed)
345 assert(!rpObj || rpObj->GetOwner() != pNew->
GetOwner());
377 SAL_WARN(
"sw.core",
"SwCache overflow.");
379 return Insert(pNew, isDuplicateOwnerAllowed);
460 m_nCachePos( USHRT_MAX ),
473 assert(
m_nLock < UCHAR_MAX &&
"Too many Locks for CacheObject." );
479 assert(
m_nLock &&
"No more Locks available." );
492 OSL_ENSURE( !
m_pObj,
"SwCacheAcces Obj already available." );
void Get_(bool isDuplicateOwnerAllowed)
virtual SwCacheObj * NewObj()=0
Can be use in NewObj.
The Cache object base class Users of the Cache must derive a class from the SwCacheObj and store thei...
void SetNext(SwCacheObj *pNew)
sal_uInt8 m_nLock
Position in the Cache array.
sal_uInt16 GetCachePos() const
const void * GetOwner() const
SwCacheObj(const void *pOwner)
bool IsOwner(const void *pNew) const
void SetPrev(SwCacheObj *pNew)
void SetCachePos(const sal_uInt16 nNew)
std::vector< sal_uInt16 > m_aFreePositions
bool Insert(SwCacheObj *pNew, bool isDuplicateOwnerAllowed)
tools::Long m_nFlushedObjects
number of flush calls
tools::Long m_nGetSeek
number of explicit deletes
tools::Long m_nReplace
number of entries inserted on freed position
void Delete(const void *pOwner, sal_uInt16 nIndex)
SwCacheObj * m_pLast
The virtual first, only different to m_pRealFirst when SetLRUOfst has been called.
tools::Long m_nFlushCnt
number of seeks for all gets without index
SwCacheObj * m_pFirst
ALWAYS the real first LRU
void ToTop(SwCacheObj *pObj)
SwCache(const sal_uInt16 nInitSize, OString aNm)
void IncreaseMax(const sal_uInt16 nAdd)
std::vector< std::unique_ptr< SwCacheObj > > m_aCacheObjects
void DecreaseMax(const sal_uInt16 nSub)
tools::Long m_nAverageSeekCnt
number of gets without index
void Check()
number of cache size decreases
void SetLRUOfst(const sal_uInt16 nOfst)
Mark some entries as "do not delete".
void DeleteObj(SwCacheObj *pObj)
~SwCache()
The dtor will free all objects still in the vector.
tools::Long m_nDecreaseMax
number of cache size increases
tools::Long m_nGetSuccess
number of LRU replacements
SwCacheObj * Get(const void *pOwner, const bool bToTop=true)
tools::Long m_nDelete
number of reordering (LRU)
SwCacheObj * m_pRealFirst
Free positions for the Insert if the maximum has not been reached Every time an object is deregistere...
tools::Long m_nInsertFree
number of entries appended
tools::Long m_nIncreaseMax
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::enable_if< std::is_signed< T >::value, bool >::type checked_add(T a, T b, T &result)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
ContentProvider * m_pOwner