summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-07-09 13:43:30 +0200
committerNoel Grandin <noel@peralex.com>2014-07-10 11:04:13 +0200
commitbc30f938c0d27ee1ae20b0c10d3d8840557b2e93 (patch)
tree0a77d8983bcb74f763e08fc0f35b6c0d478416db /store
parent0ae79a13686f2c17e6e4bda89b21fe78b5466201 (diff)
use SimpleReferenceObject in stoc module
to replace hand-rolled version Change-Id: I30635aec81313e4e0d1b67b30c8992fd63bb1f67
Diffstat (limited to 'store')
-rw-r--r--store/Library_store.mk1
-rw-r--r--store/source/lockbyte.cxx45
-rw-r--r--store/source/lockbyte.hxx5
-rw-r--r--store/source/object.cxx55
-rw-r--r--store/source/object.hxx21
-rw-r--r--store/source/storbase.cxx11
-rw-r--r--store/source/storbase.hxx5
-rw-r--r--store/source/storcach.cxx14
-rw-r--r--store/source/storcach.hxx4
-rw-r--r--store/workben/t_page.cxx2
10 files changed, 15 insertions, 148 deletions
diff --git a/store/Library_store.mk b/store/Library_store.mk
index 85d9f0e31982..d5b02c0e6b97 100644
--- a/store/Library_store.mk
+++ b/store/Library_store.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_Library_add_defs,store,\
$(eval $(call gb_Library_use_libraries,store,\
sal \
+ salhelper \
$(gb_UWINAPI) \
))
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index fff199956087..1fd9a0d0bf09 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -308,11 +308,6 @@ public:
*/
explicit FileLockBytes (FileHandle & rFile);
- /** Delegate multiple inherited IReference.
- */
- virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
- virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
-
protected:
/** Destruction.
*/
@@ -331,16 +326,6 @@ FileLockBytes::~FileLockBytes()
FileHandle::closeFile (m_hFile);
}
-oslInterlockedCount SAL_CALL FileLockBytes::acquire()
-{
- return OStoreObject::acquire();
-}
-
-oslInterlockedCount SAL_CALL FileLockBytes::release()
-{
- return OStoreObject::release();
-}
-
storeError FileLockBytes::initSize_Impl (sal_uInt32 & rnSize)
{
/* osl_getFileSize() uses slow 'fstat(h, &size)',
@@ -548,11 +533,6 @@ public:
*/
explicit MappedLockBytes (FileMapping & rMapping);
- /** Delegate multiple inherited IReference.
- */
- virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
- virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
-
protected:
/* Destruction.
*/
@@ -571,16 +551,6 @@ MappedLockBytes::~MappedLockBytes()
FileMapping::unmapFile (m_hFile, m_pData, m_nSize);
}
-oslInterlockedCount SAL_CALL MappedLockBytes::acquire()
-{
- return OStoreObject::acquire();
-}
-
-oslInterlockedCount SAL_CALL MappedLockBytes::release()
-{
- return OStoreObject::release();
-}
-
void MappedLockBytes::allocate_Impl (void ** ppPage, sal_uInt16 * pnSize)
{
OSL_PRECOND((ppPage != 0) && (pnSize != 0), "contract violation");
@@ -696,11 +666,6 @@ public:
*/
MemoryLockBytes();
- /** Delegate multiple inherited IReference.
- */
- virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
- virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
-
protected:
/** Destruction.
*/
@@ -718,16 +683,6 @@ MemoryLockBytes::~MemoryLockBytes()
rtl_freeMemory (m_pData);
}
-oslInterlockedCount SAL_CALL MemoryLockBytes::acquire (void)
-{
- return OStoreObject::acquire();
-}
-
-oslInterlockedCount SAL_CALL MemoryLockBytes::release (void)
-{
- return OStoreObject::release();
-}
-
storeError MemoryLockBytes::initialize_Impl (rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize)
{
storeError result = PageData::Allocator::createInstance (rxAllocator, nPageSize);
diff --git a/store/source/lockbyte.hxx b/store/source/lockbyte.hxx
index 591821894ff1..c9aa2a526905 100644
--- a/store/source/lockbyte.hxx
+++ b/store/source/lockbyte.hxx
@@ -24,6 +24,7 @@
#include "rtl/ref.hxx"
#include "rtl/ustring.h"
+#include "salhelper/simplereferenceobject.hxx"
#include "store/types.h"
#include "storbase.hxx"
@@ -36,7 +37,7 @@ namespace store
* ILockBytes interface.
*
*======================================================================*/
-class ILockBytes : public rtl::IReference
+class ILockBytes : public virtual salhelper::SimpleReferenceObject
{
public:
/**
@@ -103,7 +104,7 @@ public:
storeError flush();
protected:
- ~ILockBytes() {}
+ virtual ~ILockBytes() {}
private:
/** Implementation (abstract).
diff --git a/store/source/object.cxx b/store/source/object.cxx
index 1cac71d7e519..53d1c089f690 100644
--- a/store/source/object.cxx
+++ b/store/source/object.cxx
@@ -36,38 +36,6 @@ namespace store
const sal_uInt32 OStoreObject::m_nTypeId = sal_uInt32(0x58190322);
/*
- * OStoreObject.
- */
-OStoreObject::OStoreObject (void)
- : m_nRefCount (0)
-{
-}
-
-/*
- * ~OStoreObject.
- */
-OStoreObject::~OStoreObject (void)
-{
- OSL_ASSERT(m_nRefCount == 0);
-}
-
-/*
- * operator new.
- */
-void* OStoreObject::operator new (size_t n)
-{
- return rtl_allocateMemory (n);
-}
-
-/*
- * operator delete.
- */
-void OStoreObject::operator delete (void *p)
-{
- rtl_freeMemory (p);
-}
-
-/*
* isKindOf.
*/
bool OStoreObject::isKindOf (sal_uInt32 nTypeId)
@@ -75,29 +43,6 @@ bool OStoreObject::isKindOf (sal_uInt32 nTypeId)
return (nTypeId == m_nTypeId);
}
-/*
- * acquire.
- */
-oslInterlockedCount SAL_CALL OStoreObject::acquire (void)
-{
- oslInterlockedCount result = osl_atomic_increment (&m_nRefCount);
- return (result);
-}
-
-/*
- * release.
- */
-oslInterlockedCount SAL_CALL OStoreObject::release (void)
-{
- oslInterlockedCount result = osl_atomic_decrement (&m_nRefCount);
- if (result == 0)
- {
- // Last reference released.
- delete this;
- }
- return (result);
-}
-
} // namespace store
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/store/source/object.hxx b/store/source/object.hxx
index 2743bfdc692d..2b93a6f90a6a 100644
--- a/store/source/object.hxx
+++ b/store/source/object.hxx
@@ -21,10 +21,9 @@
#define INCLUDED_STORE_SOURCE_OBJECT_HXX
#include "sal/types.h"
-
#include "rtl/ref.hxx"
-
#include "osl/interlck.h"
+#include "salhelper/simplereferenceobject.hxx"
namespace store
{
@@ -34,7 +33,7 @@ namespace store
* IStoreHandle interface.
*
*======================================================================*/
-class IStoreHandle : public rtl::IReference
+class IStoreHandle : public virtual salhelper::SimpleReferenceObject
{
public:
/** Replaces dynamic_cast type checking.
@@ -42,7 +41,7 @@ public:
virtual bool isKindOf (sal_uInt32 nTypeId) = 0;
protected:
- ~IStoreHandle() {}
+ virtual ~IStoreHandle() {}
};
/** Template helper function as dynamic_cast replacement.
@@ -66,26 +65,16 @@ class OStoreObject : public store::IStoreHandle
public:
/** Construction.
*/
- OStoreObject (void);
-
- /** Allocation.
- */
- static void* operator new (size_t n);
- static void operator delete (void *p);
+ OStoreObject() {}
/** IStoreHandle.
*/
virtual bool isKindOf (sal_uInt32 nTypeId) SAL_OVERRIDE;
- /** IReference.
- */
- virtual oslInterlockedCount SAL_CALL acquire (void) SAL_OVERRIDE;
- virtual oslInterlockedCount SAL_CALL release (void) SAL_OVERRIDE;
-
protected:
/** Destruction.
*/
- virtual ~OStoreObject (void);
+ virtual ~OStoreObject() {}
private:
/** The IStoreHandle TypeId.
diff --git a/store/source/storbase.cxx b/store/source/storbase.cxx
index 084309872052..fb14595bdf01 100644
--- a/store/source/storbase.cxx
+++ b/store/source/storbase.cxx
@@ -84,17 +84,6 @@ public:
storeError initialize (sal_uInt16 nPageSize);
- /** Delegate multiple inherited rtl::IReference.
- */
- virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE
- {
- return OStoreObject::acquire();
- }
- virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE
- {
- return OStoreObject::release();
- }
-
protected:
/** Destruction.
*/
diff --git a/store/source/storbase.hxx b/store/source/storbase.hxx
index 1c6205c5ea44..2b74bf057bc5 100644
--- a/store/source/storbase.hxx
+++ b/store/source/storbase.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_STORE_SOURCE_STORBASE_HXX
#include "sal/config.h"
+#include "salhelper/simplereferenceobject.hxx"
#include "boost/static_assert.hpp"
#include "sal/types.h"
@@ -454,7 +455,7 @@ struct PageData
/** Allocation.
*/
class Allocator_Impl;
- class Allocator : public rtl::IReference
+ class Allocator : public virtual salhelper::SimpleReferenceObject
{
public:
template< class T > T * construct()
@@ -483,7 +484,7 @@ struct PageData
rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize);
protected:
- ~Allocator() {}
+ virtual ~Allocator() {}
private:
/** Implementation (abstract).
diff --git a/store/source/storcach.cxx b/store/source/storcach.cxx
index f7738f1676c3..6ddb2db389dc 100644
--- a/store/source/storcach.cxx
+++ b/store/source/storcach.cxx
@@ -274,10 +274,6 @@ public:
// Construction
explicit PageCache_Impl (sal_uInt16 nPageSize);
- // Delegate multiple inherited IReference
- virtual oslInterlockedCount SAL_CALL acquire() SAL_OVERRIDE;
- virtual oslInterlockedCount SAL_CALL release() SAL_OVERRIDE;
-
protected:
// Destruction
virtual ~PageCache_Impl (void);
@@ -330,16 +326,6 @@ PageCache_Impl::~PageCache_Impl()
OSL_TRACE("Hits: %zu, Misses: %zu", m_nHit, m_nMissed);
}
-oslInterlockedCount PageCache_Impl::acquire()
-{
- return OStoreObject::acquire();
-}
-
-oslInterlockedCount PageCache_Impl::release()
-{
- return OStoreObject::release();
-}
-
void PageCache_Impl::rescale_Impl (sal_Size new_size)
{
sal_Size new_bytes = new_size * sizeof(Entry*);
diff --git a/store/source/storcach.hxx b/store/source/storcach.hxx
index a045a8bf3529..511fbba12e3d 100644
--- a/store/source/storcach.hxx
+++ b/store/source/storcach.hxx
@@ -35,7 +35,7 @@ namespace store
*
*======================================================================*/
-class PageCache : public rtl::IReference
+class PageCache : public virtual salhelper::SimpleReferenceObject
{
public:
/** load.
@@ -62,7 +62,7 @@ public:
sal_uInt32 nOffset);
protected:
- ~PageCache() {}
+ virtual ~PageCache() {}
private:
/** Implementation (abstract).
diff --git a/store/workben/t_page.cxx b/store/workben/t_page.cxx
index 2bf4ebbd53aa..46ed2a98f4eb 100644
--- a/store/workben/t_page.cxx
+++ b/store/workben/t_page.cxx
@@ -176,7 +176,7 @@ struct PageData
/** Allocation.
*/
- class Allocator : public rtl::IReference
+ class Allocator : public salhelper::SimpleReferenceObject
{
public:
template< class T > T * construct()