summaryrefslogtreecommitdiff
path: root/store/source/storcach.hxx
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2009-03-13 15:52:34 +0000
committerVladimir Glazounov <vg@openoffice.org>2009-03-13 15:52:34 +0000
commitcbedb240486a21c5d5676e7a7f4e2ba17a55dbab (patch)
treeec2690bb5e5d18df0a9493c54cfac64f9e5ab494 /store/source/storcach.hxx
parent32a3f76b3695cbf54fecc77730395bbace21c8bc (diff)
CWS-TOOLING: integrate CWS mhu17
2009-01-23 14:08:09 +0100 mhu r266816 : CWS-TOOLING: rebase CWS mhu17 to trunk@266428 (milestone: DEV300:m39) 2009-01-16 17:49:37 +0100 mhu r266442 : #i98151# Migration to subversion. 2009-01-16 17:48:53 +0100 mhu r266441 : #i98151# Migration to subversion. 2009-01-16 17:47:56 +0100 mhu r266440 : #i98151# Migration to subversion.
Diffstat (limited to 'store/source/storcach.hxx')
-rw-r--r--store/source/storcach.hxx179
1 files changed, 50 insertions, 129 deletions
diff --git a/store/source/storcach.hxx b/store/source/storcach.hxx
index 661343657be5..eb98bb786df5 100644
--- a/store/source/storcach.hxx
+++ b/store/source/storcach.hxx
@@ -29,158 +29,79 @@
************************************************************************/
#ifndef _STORE_STORCACH_HXX
-#define _STORE_STORCACH_HXX "$Revision: 1.6 $"
+#define _STORE_STORCACH_HXX "$Revision: 1.6.8.2 $"
-#include <sal/types.h>
-#include <osl/mutex.hxx>
-#include <store/types.h>
+#include "sal/types.h"
+#include "rtl/ref.hxx"
-#ifndef INCLUDED_CSTDDEF
-#include <cstddef>
-#define INCLUDED_CSTDDEF
-#endif
+#include "store/types.h"
+#include "storbase.hxx"
namespace store
{
-struct OStorePageDescriptor;
-struct OStorePageData;
-class OStorePageBIOS;
-
/*========================================================================
*
- * OStorePageCache interface.
- * (OStorePageData in external representation)
+ * PageCache interface.
*
*======================================================================*/
-#define STORE_LIMIT_CACHEPAGES 256
-#define STORE_DEFAULT_CACHEPAGES STORE_LIMIT_CACHEPAGES
-
-struct OStorePageCacheEntry;
-class OStorePageCache
+class PageCache : public rtl::IReference
{
- typedef OStorePageCacheEntry entry;
-
public:
- /** Allocation.
+ /** load.
*/
- static void * operator new (std::size_t n) SAL_THROW(());
- static void operator delete (void * p, std::size_t) SAL_THROW(());
-
- /** Construction.
- */
- OStorePageCache (
- sal_uInt16 nPages = STORE_DEFAULT_CACHEPAGES);
+ storeError lookupPageAt (
+ PageHolder & rxPage,
+ sal_uInt32 nOffset);
- /** Destruction.
- */
- ~OStorePageCache (void);
+ /** insert.
+ */
+ storeError insertPageAt (
+ PageHolder const & rxPage,
+ sal_uInt32 nOffset);
- /** load.
- */
- storeError load (
- const OStorePageDescriptor &rDescr,
- OStorePageData &rData,
- OStorePageBIOS &rBIOS,
- osl::Mutex *pMutex = NULL);
-
- /** update.
- */
- enum UpdateMode
- {
- UPDATE_WRITE_THROUGH = 0,
- UPDATE_WRITE_DELAYED = 1
- };
-
- storeError update (
- const OStorePageDescriptor &rDescr,
- const OStorePageData &rData,
- OStorePageBIOS &rBIOS,
- osl::Mutex *pMutex = NULL,
- UpdateMode eMode = UPDATE_WRITE_THROUGH);
-
- /** invalidate.
- */
- storeError invalidate (
- const OStorePageDescriptor &rDescr,
- osl::Mutex *pMutex = NULL);
-
- /** flush.
- */
- storeError flush (
- OStorePageBIOS &rBIOS,
- osl::Mutex *pMutex = NULL);
-
- /** hitRatio [nHit / (nHit + nMissed)].
+ /** update, or insert.
*/
- inline double hitRatio (void) const;
+ storeError updatePageAt (
+ PageHolder const & rxPage,
+ sal_uInt32 nOffset);
- /** usageRatio [nUsed / nSize].
- */
- inline double usageRatio (void) const;
+ /** remove (invalidate).
+ */
+ storeError removePageAt (
+ sal_uInt32 nOffset);
private:
- /** Representation.
- */
- sal_uInt16 m_nSize;
- sal_uInt16 m_nUsed;
- entry *m_pData[STORE_LIMIT_CACHEPAGES];
- entry *m_pHead;
-
- sal_uInt32 m_nHit;
- sal_uInt32 m_nMissed;
- sal_uInt32 m_nUpdHit;
- sal_uInt32 m_nUpdLRU;
- sal_uInt32 m_nWrtBack;
-
- /** Implementation.
- */
- sal_uInt16 find (const OStorePageDescriptor &rDescr) const;
- void move (sal_uInt16 nSI, sal_uInt16 nDI);
+ /** Implementation (abstract).
+ */
+ virtual storeError lookupPageAt_Impl (
+ PageHolder & rxPage,
+ sal_uInt32 nOffset) = 0;
- /** insert.
- */
- enum InsertMode
- {
- INSERT_CLEAN = 0,
- INSERT_DIRTY = 1
- };
-
- storeError insert (
- sal_uInt16 nIndex,
- const OStorePageDescriptor &rDescr,
- const OStorePageData &rData,
- OStorePageBIOS &rBIOS,
- InsertMode eMode = INSERT_CLEAN);
-
- /** Not implemented.
- */
- OStorePageCache (const OStorePageCache& rOther);
- OStorePageCache& operator= (const OStorePageCache& rOther);
+ virtual storeError insertPageAt_Impl (
+ PageHolder const & rxPage,
+ sal_uInt32 nOffset) = 0;
+
+ virtual storeError updatePageAt_Impl (
+ PageHolder const & rxPage,
+ sal_uInt32 nOffset) = 0;
+
+ virtual storeError removePageAt_Impl (
+ sal_uInt32 nOffset) = 0;
};
-/*
- * hitRatio [nHit / (nHit + nMissed)].
- */
-inline double OStorePageCache::hitRatio (void) const
-{
- if (m_nHit || m_nMissed)
- return ((double)m_nHit / (double)(m_nHit + m_nMissed));
- else
- return 1.0;
-}
-
-/*
- * usageRatio [nUsed / nSize].
- */
-inline double OStorePageCache::usageRatio (void) const
-{
- if (m_nUsed < m_nSize)
- return ((double)m_nUsed / (double)m_nSize);
- else
- return 1.0;
-}
+/*========================================================================
+ *
+ * PageCache factory.
+ *
+ *======================================================================*/
+
+storeError
+PageCache_createInstance (
+ rtl::Reference< store::PageCache > & rxCache,
+ sal_uInt16 nPageSize
+);
/*========================================================================
*