shared.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GPGMEPP_SHARED_H__
00022 #define __GPGMEPP_SHARED_H__
00023
00024 #include <cassert>
00025
00026 namespace GpgME {
00027
00028 class Shared {
00029 protected:
00030 Shared() : mRefCount( 0 ) {}
00031 virtual ~Shared() {
00032 assert( mRefCount <= 0 );
00033 }
00034
00035 public:
00036 int ref() { return ++mRefCount; }
00037 int deref() { return unref(); }
00038 int unref() {
00039 if ( --mRefCount <= 0 ) {
00040 delete this;
00041 return 0;
00042 }
00043 return mRefCount;
00044 }
00045 int refCount() { return mRefCount; }
00046
00047 private:
00048 int mRefCount;
00049 };
00050
00051 }
00052
00053
00054 #endif // __GPGMEPP_SHARED_H__
This file is part of the documentation for libkdenetwork Library Version 3.3.2.