[Libreoffice-commits] core.git: include/tools
Noel Grandin
noel at peralex.com
Sun Jul 13 23:54:43 PDT 2014
include/tools/ref.hxx | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
New commits:
commit c6c5789ae894847d12c5d12a6d8aafc2849cb36e
Author: Noel Grandin <noel at peralex.com>
Date: Thu Jul 10 12:12:55 2014 +0200
include/tools/ref.hxx - cleanup formatting
Change-Id: I1f7f566ea80723b188aab9c2f65437ca902ce9b9
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index 32d7604..a6782f0 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -33,13 +33,22 @@ public:
SvRef(): pObj(0) {}
SvRef(SvRef const & rObj): pObj(rObj.pObj)
- { if (pObj != 0) pObj->AddNextRef(); }
+ {
+ if (pObj != 0) pObj->AddNextRef();
+ }
- SvRef(T * pObjP): pObj(pObjP) { if (pObj != 0) pObj->AddRef(); }
+ SvRef(T * pObjP): pObj(pObjP)
+ {
+ if (pObj != 0) pObj->AddRef();
+ }
- ~SvRef() { if (pObj != 0) pObj->ReleaseRef(); }
+ ~SvRef()
+ {
+ if (pObj != 0) pObj->ReleaseRef();
+ }
- void Clear() {
+ void Clear()
+ {
if (pObj != 0) {
T * pRefObj = pObj;
pObj = 0;
@@ -47,7 +56,8 @@ public:
}
}
- SvRef & operator =(SvRef const & rObj) {
+ SvRef & operator =(SvRef const & rObj)
+ {
if (rObj.pObj != 0) {
rObj.pObj->AddNextRef();
}
@@ -59,15 +69,15 @@ public:
return *this;
}
- bool Is() const { return pObj != 0; }
+ bool Is() const { return pObj != 0; }
- T * operator &() const { return pObj; }
+ T * operator &() const { return pObj; }
T * operator ->() const { assert(pObj != 0); return pObj; }
- T & operator *() const { assert(pObj != 0); return *pObj; }
+ T & operator *() const { assert(pObj != 0); return *pObj; }
- operator T *() const { return pObj; }
+ operator T *() const { return pObj; }
protected:
T * pObj;
@@ -131,10 +141,10 @@ public:
}
};
-#define SV_NO_DELETE_REFCOUNT 0x80000000
class TOOLS_DLLPUBLIC SvRefBase
{
+ static const sal_uIntPtr SV_NO_DELETE_REFCOUNT = 0x80000000;
sal_uIntPtr nRefCount;
protected:
@@ -142,29 +152,39 @@ protected:
virtual void QueryDelete();
public:
- SvRefBase() { nRefCount = SV_NO_DELETE_REFCOUNT; }
+ SvRefBase()
+ { nRefCount = SV_NO_DELETE_REFCOUNT; }
+
SvRefBase( const SvRefBase & /* rObj */ )
{ nRefCount = SV_NO_DELETE_REFCOUNT; }
- SvRefBase & operator = ( const SvRefBase & ) { return *this; }
+
+ SvRefBase & operator = ( const SvRefBase & )
+ { return *this; }
void RestoreNoDelete()
{
if( nRefCount < SV_NO_DELETE_REFCOUNT )
nRefCount += SV_NO_DELETE_REFCOUNT;
}
- sal_uIntPtr AddNextRef() { return ++nRefCount; }
+
+ sal_uIntPtr AddNextRef()
+ { return ++nRefCount; }
+
sal_uIntPtr AddRef()
{
if( nRefCount >= SV_NO_DELETE_REFCOUNT )
nRefCount -= SV_NO_DELETE_REFCOUNT;
return ++nRefCount;
}
+
void ReleaseRef()
{
if( !--nRefCount )
QueryDelete();
}
- sal_uIntPtr GetRefCount() const { return nRefCount; }
+
+ sal_uIntPtr GetRefCount() const
+ { return nRefCount; }
};
typedef tools::SvRef<SvRefBase> SvRefBaseRef;
@@ -177,7 +197,7 @@ class SvCompatWeakHdl : public SvRefBase
public:
void ResetWeakBase( ) { _pObj = 0; }
- void* GetObj() { return _pObj; }
+ void* GetObj() { return _pObj; }
};
typedef tools::SvRef<SvCompatWeakHdl> SvCompatWeakHdlRef;
More information about the Libreoffice-commits
mailing list