QSharedDataPointer< T > Class Template Reference

QSharedDataPointer< T > Class Template Reference

#include <qshareddata.h>

Class Description

template<class T>
class QSharedDataPointer< T >

Definition at line 54 of file qshareddata.h.

Public Types

typedef T Type
 
typedef T * pointer
 

Public Member Functions

void detach ()
 
T & operator* ()
 
const T & operator* () const
 
T * operator-> ()
 
const T * operator-> () const
 
 operator T * ()
 
 operator const T * () const
 
T * data ()
 
const T * data () const
 
const T * constData () const
 
bool operator== (const QSharedDataPointer< T > &other) const
 
bool operator!= (const QSharedDataPointer< T > &other) const
 
 QSharedDataPointer ()
 
 ~QSharedDataPointer ()
 
 QSharedDataPointer (T *data)
 
 QSharedDataPointer (const QSharedDataPointer< T > &o)
 
QSharedDataPointer< T > & operator= (const QSharedDataPointer< T > &o)
 
QSharedDataPointeroperator= (T *o)
 
bool operator! () const
 
void swap (QSharedDataPointer &other)
 

Protected Member Functions

T * clone ()
 

Member Typedef Documentation

typedef T Type

Definition at line 72 of file qshareddata.h.

typedef T* pointer

Definition at line 73 of file qshareddata.h.

Constructor & Destructor Documentation

QSharedDataPointer ( )
inline

Definition at line 89 of file qshareddata.h.

89 { d = 0; }
~QSharedDataPointer ( )
inline

Definition at line 90 of file qshareddata.h.

90 { if (d && !d->ref.deref()) delete d; }
Q_INLINE_TEMPLATE QSharedDataPointer ( T *  data)
explicit

Definition at line 221 of file qshareddata.h.

221  : d(adata)
222 { if (d) d->ref.ref(); }
QSharedDataPointer ( const QSharedDataPointer< T > &  o)
inline

Definition at line 93 of file qshareddata.h.

93 : d(o.d) { if (d) d->ref.ref(); }

Member Function Documentation

void detach ( )
inline

Definition at line 75 of file qshareddata.h.

75 { if (d && d->ref != 1) detach_helper(); }
T& operator* ( )
inline

Definition at line 76 of file qshareddata.h.

76 { detach(); return *d; }
const T& operator* ( ) const
inline

Definition at line 77 of file qshareddata.h.

77 { return *d; }
T* operator-> ( void  )
inline

Definition at line 78 of file qshareddata.h.

78 { detach(); return d; }
const T* operator-> ( void  ) const
inline

Definition at line 79 of file qshareddata.h.

79 { return d; }
operator T * ( )
inline

Definition at line 80 of file qshareddata.h.

80 { detach(); return d; }
operator const T * ( ) const
inline

Definition at line 81 of file qshareddata.h.

81 { return d; }
T* data ( )
inline

Definition at line 82 of file qshareddata.h.

82 { detach(); return d; }
const T* data ( ) const
inline

Definition at line 83 of file qshareddata.h.

83 { return d; }
const T* constData ( ) const
inline

Definition at line 84 of file qshareddata.h.

84 { return d; }
bool operator== ( const QSharedDataPointer< T > &  other) const
inline

Definition at line 86 of file qshareddata.h.

86 { return d == other.d; }
bool operator!= ( const QSharedDataPointer< T > &  other) const
inline

Definition at line 87 of file qshareddata.h.

87 { return d != other.d; }
QSharedDataPointer<T>& operator= ( const QSharedDataPointer< T > &  o)
inline

Definition at line 94 of file qshareddata.h.

94  {
95  if (o.d != d) {
96  if (o.d)
97  o.d->ref.ref();
98  T *old = d;
99  d = o.d;
100  if (old && !old->ref.deref())
101  delete old;
102  }
103  return *this;
104  }
QSharedDataPointer& operator= ( T *  o)
inline

Definition at line 105 of file qshareddata.h.

105  {
106  if (o != d) {
107  if (o)
108  o->ref.ref();
109  T *old = d;
110  d = o;
111  if (old && !old->ref.deref())
112  delete old;
113  }
114  return *this;
115  }
bool operator! ( void  ) const
inline

Definition at line 122 of file qshareddata.h.

122 { return !d; }
void swap ( QSharedDataPointer< T > &  other)
inline

Definition at line 124 of file qshareddata.h.

125  { qSwap(d, other.d); }
Q_INLINE_TEMPLATE void qSwap(QSharedDataPointer< T > &p1, QSharedDataPointer< T > &p2)
Definition: qshareddata.h:261
Q_INLINE_TEMPLATE T * clone ( )
protected

Definition at line 225 of file qshareddata.h.

226 {
227  return new T(*d);
228 }

The documentation for this class was generated from the following file: