23 #ifndef _TelepathyQt_shared_ptr_h_HEADER_GUARD_ 
   24 #define _TelepathyQt_shared_ptr_h_HEADER_GUARD_ 
   26 #ifndef IN_TP_QT_HEADER 
   27 #error IN_TP_QT_HEADER 
   30 #include <TelepathyQt/Global> 
   48         Q_DISABLE_COPY(SharedCount)
 
   52             : d(d), strongref(0), weakref(0)
 
   57         template <
class T> 
friend class SharedPtr;
 
   58         template <
class T> 
friend class WeakPtr;
 
   62         mutable QAtomicInt strongref;
 
   63         mutable QAtomicInt weakref;
 
   75         if (!sc->weakref.deref()) {
 
   89     inline void ref()
 const { sc->strongref.ref(); }
 
   90     inline bool deref()
 const { 
return sc->strongref.deref(); }
 
   98     typedef bool (SharedPtr<T>::*UnspecifiedBoolType)() 
const;
 
  102     explicit inline SharedPtr(T *d) : d(d) { 
if (d) { d->ref(); } }
 
  103     template <
typename Sub
class>
 
  108         RefCounted::SharedCount *sc = o.sc;
 
  112             register int tmp = sc->strongref.fetchAndAddOrdered(0);
 
  115                 if (sc->strongref.testAndSetRelaxed(tmp, tmp + 1)) {
 
  120                 tmp = sc->strongref.fetchAndAddOrdered(0);
 
  124                 d = 
dynamic_cast<T*
>(sc->d);
 
  136         if (d && !d->deref()) {
 
  148     inline T *
data()
 const { 
return d; }
 
  153     inline bool isNull()
 const { 
return !d; }
 
  159     inline bool operator==(
const T *ptr)
 const { 
return d == ptr; }
 
  160     inline bool operator!=(
const T *ptr)
 const { 
return d != ptr; }
 
  208     return QT_PREPEND_NAMESPACE(qHash<T>(ptr.data()));
 
  211 template<
typename T> 
inline uint 
qHash(
const WeakPtr<T> &ptr);
 
  216     typedef bool (WeakPtr<T>::*UnspecifiedBoolType)() 
const;
 
  241         if (sc && !sc->weakref.deref()) {
 
  246     inline bool isNull()
 const { 
return !sc || sc->strongref.fetchAndAddOrdered(0) <= 0; }
 
  264         RefCounted::SharedCount *tmp = sc;
 
  275     RefCounted::SharedCount *sc;
 
  281     T *actualPtr = ptr.sc ? ptr.sc.d : 0;
 
  282     return QT_PREPEND_NAMESPACE(qHash<T>(actualPtr));
 
The ContactManager class is responsible for managing contacts. 
Definition: contact-manager.h:50
WeakPtr< T > & operator=(const SharedPtr< T > &o)
Definition: shared-ptr.h:256
bool isNull() const 
Definition: shared-ptr.h:153
WeakPtr(T *d)
Definition: shared-ptr.h:220
The WeakPtr class holds a weak reference to an object managed by SharedPtr. 
Definition: shared-ptr.h:40
SharedPtr()
Definition: shared-ptr.h:101
T * operator->() const 
Definition: shared-ptr.h:151
T * data() const 
Definition: shared-ptr.h:148
WeakPtr(const SharedPtr< T > &o)
Definition: shared-ptr.h:230
bool operator!=(const T *ptr) const 
Definition: shared-ptr.h:160
static SharedPtr< T > qObjectCast(const SharedPtr< X > &src)
Definition: shared-ptr.h:194
~SharedPtr()
Definition: shared-ptr.h:134
SharedPtr(const SharedPtr< T > &o)
Definition: shared-ptr.h:105
static SharedPtr< T > staticCast(const SharedPtr< X > &src)
Definition: shared-ptr.h:176
WeakPtr(const WeakPtr< T > &o)
Definition: shared-ptr.h:229
WeakPtr< T > & operator=(const WeakPtr< T > &o)
Definition: shared-ptr.h:250
bool isNull() const 
Definition: shared-ptr.h:246
WeakPtr()
Definition: shared-ptr.h:219
The SharedPtr class is a pointer to an explicitly shared object. 
Definition: shared-ptr.h:39
RefCounted()
Definition: shared-ptr.h:67
virtual ~RefCounted()
Definition: shared-ptr.h:72
void reset()
Definition: shared-ptr.h:143
bool operator==(const SharedPtr< T > &o) const 
Definition: shared-ptr.h:157
bool operator!() const 
Definition: shared-ptr.h:247
~WeakPtr()
Definition: shared-ptr.h:239
bool operator!=(const SharedPtr< T > &o) const 
Definition: shared-ptr.h:158
const T * constData() const 
Definition: shared-ptr.h:149
SharedPtr< T > & operator=(const SharedPtr< T > &o)
Definition: shared-ptr.h:162
static SharedPtr< T > dynamicCast(const SharedPtr< X > &src)
Definition: shared-ptr.h:182
SharedPtr(const SharedPtr< Subclass > &o)
Definition: shared-ptr.h:104
void swap(WeakPtr< T > &o)
Definition: shared-ptr.h:262
void swap(SharedPtr< T > &o)
Definition: shared-ptr.h:168
uint qHash(const ChannelClassSpec &spec)
Definition: channel-class-spec.h:283
The RefCounted class is a base class for shared objects used by SharedPtr. 
Definition: shared-ptr.h:42
SharedPtr< T > toStrongRef() const 
Definition: shared-ptr.h:269
static SharedPtr< T > constCast(const SharedPtr< X > &src)
Definition: shared-ptr.h:188
bool operator==(const T *ptr) const 
Definition: shared-ptr.h:159
T * operator->()
Definition: shared-ptr.h:150
SharedPtr(T *d)
Definition: shared-ptr.h:102
SharedPtr(const WeakPtr< T > &o)
Definition: shared-ptr.h:106
bool operator!() const 
Definition: shared-ptr.h:154