summaryrefslogtreecommitdiff
path: root/include/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-04-07 09:26:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-04-07 09:26:06 +0200
commitae91e58350348e0482929230d6c9b281325ff55d (patch)
tree92a65837fe30964574b5d943eb9f3e0943c4224c /include/tools
parent97cfb1fe0163a9dc09734a761c56d149b8c61f4b (diff)
Unroll sole use of SV_IMPL/DECL_LOCK
Change-Id: I0d4691f700a415d0376e2bc346bc51fbf6a000b2
Diffstat (limited to 'include/tools')
-rw-r--r--include/tools/ref.hxx82
1 files changed, 30 insertions, 52 deletions
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index bdc055b9ee0a..e66fbb4acec2 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -22,77 +22,55 @@
#include <tools/toolsdllapi.h>
#include <vector>
-#define PRV_SV_IMPL_REF_COUNTERS( ClassName, Ref, AddRef, AddNextRef, ReleaseRef, pRefbase ) \
+#define SV_DECL_REF( ClassName ) \
+class ClassName; \
+class ClassName##Ref \
+{ \
+protected: \
+ ClassName * pObj; \
+public: \
+ inline ClassName##Ref() { pObj = 0; } \
+ inline ClassName##Ref( const ClassName##Ref & rObj ); \
+ inline ClassName##Ref( ClassName * pObjP ); \
+ inline void Clear(); \
+ inline ~ClassName##Ref(); \
+ inline ClassName##Ref & operator = ( const ClassName##Ref & rObj ); \
+ inline ClassName##Ref & operator = ( ClassName * pObj ); \
+ inline bool Is() const { return pObj != NULL; } \
+ inline ClassName * operator & () const { return pObj; } \
+ inline ClassName * operator -> () const { return pObj; } \
+ inline ClassName & operator * () const { return *pObj; } \
+ inline operator ClassName * () const { return pObj; } \
+};
+
+#define SV_IMPL_REF( ClassName ) \
inline ClassName##Ref::ClassName##Ref( const ClassName##Ref & rObj ) \
- { pObj = rObj.pObj; if( pObj ) { pRefbase->AddNextRef; } } \
+ { pObj = rObj.pObj; if( pObj ) { pObj->AddNextRef(); } } \
inline ClassName##Ref::ClassName##Ref( ClassName * pObjP ) \
-{ pObj = pObjP; if( pObj ) { pRefbase->AddRef; } } \
+{ pObj = pObjP; if( pObj ) { pObj->AddRef(); } } \
inline void ClassName##Ref::Clear() \
{ \
if( pObj ) \
{ \
- ClassName* const pRefObj = pRefbase; \
+ ClassName* const pRefObj = pObj; \
pObj = 0; \
- pRefObj->ReleaseRef; \
+ pRefObj->ReleaseReference(); \
} \
} \
inline ClassName##Ref::~ClassName##Ref() \
-{ if( pObj ) { pRefbase->ReleaseRef; } } \
+{ if( pObj ) { pObj->ReleaseReference(); } } \
inline ClassName##Ref & ClassName##Ref:: \
operator = ( const ClassName##Ref & rObj ) \
{ \
- if( rObj.pObj ) rObj.pRefbase->AddNextRef; \
- ClassName* const pRefObj = pRefbase; \
+ if( rObj.pObj ) rObj.pObj->AddNextRef(); \
+ ClassName* const pRefObj = pObj; \
pObj = rObj.pObj; \
- if( pRefObj ) { pRefObj->ReleaseRef; } \
+ if( pRefObj ) { pRefObj->ReleaseReference(); } \
return *this; \
} \
inline ClassName##Ref & ClassName##Ref::operator = ( ClassName * pObjP ) \
{ return *this = ClassName##Ref( pObjP ); }
-#define PRV_SV_DECL_REF_LOCK(ClassName, Ref) \
-protected: \
- ClassName * pObj; \
-public: \
- inline ClassName##Ref() { pObj = 0; } \
- inline ClassName##Ref( const ClassName##Ref & rObj ); \
- inline ClassName##Ref( ClassName * pObjP ); \
- inline void Clear(); \
- inline ~ClassName##Ref(); \
- inline ClassName##Ref & operator = ( const ClassName##Ref & rObj ); \
- inline ClassName##Ref & operator = ( ClassName * pObj ); \
- inline bool Is() const { return pObj != NULL; } \
- inline ClassName * operator & () const { return pObj; } \
- inline ClassName * operator -> () const { return pObj; } \
- inline ClassName & operator * () const { return *pObj; } \
- inline operator ClassName * () const { return pObj; }
-
-#define PRV_SV_DECL_REF( ClassName ) \
-PRV_SV_DECL_REF_LOCK( ClassName, Ref )
-
-#define SV_DECL_REF( ClassName ) \
-class ClassName; \
-class ClassName##Ref \
-{ \
- PRV_SV_DECL_REF( ClassName ) \
-};
-
-#define SV_DECL_LOCK( ClassName ) \
-class ClassName; \
-class ClassName##Lock \
-{ \
- PRV_SV_DECL_REF_LOCK( ClassName, Lock ) \
-};
-
-#define SV_IMPL_REF( ClassName ) \
-PRV_SV_IMPL_REF_COUNTERS( ClassName, Ref, AddRef(), AddNextRef(),\
- ReleaseReference(), pObj )
-
-#define SV_IMPL_LOCK( ClassName ) \
-PRV_SV_IMPL_REF_COUNTERS( ClassName, Lock, OwnerLock( true ), \
- OwnerLock( true ), OwnerLock( false ), \
- pObj )
-
#define SV_DECL_IMPL_REF(ClassName) \
SV_DECL_REF(ClassName) \
SV_IMPL_REF(ClassName)