Kaydet (Commit) c6c5789a authored tarafından Noel Grandin's avatar Noel Grandin

include/tools/ref.hxx - cleanup formatting

Change-Id: I1f7f566ea80723b188aab9c2f65437ca902ce9b9
üst c05cecbe
...@@ -33,13 +33,22 @@ public: ...@@ -33,13 +33,22 @@ public:
SvRef(): pObj(0) {} SvRef(): pObj(0) {}
SvRef(SvRef const & rObj): pObj(rObj.pObj) 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) { if (pObj != 0) {
T * pRefObj = pObj; T * pRefObj = pObj;
pObj = 0; pObj = 0;
...@@ -47,7 +56,8 @@ public: ...@@ -47,7 +56,8 @@ public:
} }
} }
SvRef & operator =(SvRef const & rObj) { SvRef & operator =(SvRef const & rObj)
{
if (rObj.pObj != 0) { if (rObj.pObj != 0) {
rObj.pObj->AddNextRef(); rObj.pObj->AddNextRef();
} }
...@@ -131,10 +141,10 @@ public: ...@@ -131,10 +141,10 @@ public:
} }
}; };
#define SV_NO_DELETE_REFCOUNT 0x80000000
class TOOLS_DLLPUBLIC SvRefBase class TOOLS_DLLPUBLIC SvRefBase
{ {
static const sal_uIntPtr SV_NO_DELETE_REFCOUNT = 0x80000000;
sal_uIntPtr nRefCount; sal_uIntPtr nRefCount;
protected: protected:
...@@ -142,29 +152,39 @@ protected: ...@@ -142,29 +152,39 @@ protected:
virtual void QueryDelete(); virtual void QueryDelete();
public: public:
SvRefBase() { nRefCount = SV_NO_DELETE_REFCOUNT; } SvRefBase()
{ nRefCount = SV_NO_DELETE_REFCOUNT; }
SvRefBase( const SvRefBase & /* rObj */ ) SvRefBase( const SvRefBase & /* rObj */ )
{ nRefCount = SV_NO_DELETE_REFCOUNT; } { nRefCount = SV_NO_DELETE_REFCOUNT; }
SvRefBase & operator = ( const SvRefBase & ) { return *this; }
SvRefBase & operator = ( const SvRefBase & )
{ return *this; }
void RestoreNoDelete() void RestoreNoDelete()
{ {
if( nRefCount < SV_NO_DELETE_REFCOUNT ) if( nRefCount < SV_NO_DELETE_REFCOUNT )
nRefCount += SV_NO_DELETE_REFCOUNT; nRefCount += SV_NO_DELETE_REFCOUNT;
} }
sal_uIntPtr AddNextRef() { return ++nRefCount; }
sal_uIntPtr AddNextRef()
{ return ++nRefCount; }
sal_uIntPtr AddRef() sal_uIntPtr AddRef()
{ {
if( nRefCount >= SV_NO_DELETE_REFCOUNT ) if( nRefCount >= SV_NO_DELETE_REFCOUNT )
nRefCount -= SV_NO_DELETE_REFCOUNT; nRefCount -= SV_NO_DELETE_REFCOUNT;
return ++nRefCount; return ++nRefCount;
} }
void ReleaseRef() void ReleaseRef()
{ {
if( !--nRefCount ) if( !--nRefCount )
QueryDelete(); QueryDelete();
} }
sal_uIntPtr GetRefCount() const { return nRefCount; }
sal_uIntPtr GetRefCount() const
{ return nRefCount; }
}; };
typedef tools::SvRef<SvRefBase> SvRefBaseRef; typedef tools::SvRef<SvRefBase> SvRefBaseRef;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment