QExplicitlySharedDataPointer< T > Class Template Reference

QExplicitlySharedDataPointer< T > Class Template Reference

#include <qshareddata.h>

Class Description

template<class T>
class QExplicitlySharedDataPointer< T >

Definition at line 136 of file qshareddata.h.

Public Types

typedef T Type
 
typedef T * pointer
 

Public Member Functions

T & operator* () const
 
T * operator-> ()
 
T * operator-> () const
 
T * data () const
 
const T * constData () const
 
void detach ()
 
void reset ()
 
 operator bool () const
 
bool operator== (const QExplicitlySharedDataPointer< T > &other) const
 
bool operator!= (const QExplicitlySharedDataPointer< T > &other) const
 
bool operator== (const T *ptr) const
 
bool operator!= (const T *ptr) const
 
 QExplicitlySharedDataPointer ()
 
 ~QExplicitlySharedDataPointer ()
 
 QExplicitlySharedDataPointer (T *data)
 
 QExplicitlySharedDataPointer (const QExplicitlySharedDataPointer< T > &o)
 
template<class X >
 QExplicitlySharedDataPointer (const QExplicitlySharedDataPointer< X > &o)
 
QExplicitlySharedDataPointer< T > & operator= (const QExplicitlySharedDataPointer< T > &o)
 
QExplicitlySharedDataPointeroperator= (T *o)
 
bool operator! () const
 
void swap (QExplicitlySharedDataPointer &other)
 

Protected Member Functions

T * clone ()
 

Member Typedef Documentation

typedef T Type

Definition at line 139 of file qshareddata.h.

typedef T* pointer

Definition at line 140 of file qshareddata.h.

Constructor & Destructor Documentation

Definition at line 165 of file qshareddata.h.

165 { d = 0; }

Definition at line 166 of file qshareddata.h.

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

Definition at line 257 of file qshareddata.h.

257  : d(adata)
258 { if (d) d->ref.ref(); }

Definition at line 169 of file qshareddata.h.

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

Definition at line 172 of file qshareddata.h.

172  : d(static_cast<T *>(o.data()))
173  {
174  if(d)
175  d->ref.ref();
176  }

Member Function Documentation

T& operator* ( ) const
inline

Definition at line 142 of file qshareddata.h.

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

Definition at line 143 of file qshareddata.h.

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

Definition at line 144 of file qshareddata.h.

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

Definition at line 145 of file qshareddata.h.

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

Definition at line 146 of file qshareddata.h.

146 { return d; }
void detach ( )
inline

Definition at line 148 of file qshareddata.h.

148 { if (d && d->ref != 1) detach_helper(); }
void reset ( )
inline

Definition at line 150 of file qshareddata.h.

151  {
152  if(d && !d->ref.deref())
153  delete d;
154 
155  d = 0;
156  }
operator bool ( ) const
inline

Definition at line 158 of file qshareddata.h.

158 { return d != 0; }
bool operator== ( const QExplicitlySharedDataPointer< T > &  other) const
inline

Definition at line 160 of file qshareddata.h.

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

Definition at line 161 of file qshareddata.h.

161 { return d != other.d; }
bool operator== ( const T *  ptr) const
inline

Definition at line 162 of file qshareddata.h.

162 { return d == ptr; }
bool operator!= ( const T *  ptr) const
inline

Definition at line 163 of file qshareddata.h.

163 { return d != ptr; }
QExplicitlySharedDataPointer<T>& operator= ( const QExplicitlySharedDataPointer< T > &  o)
inline

Definition at line 178 of file qshareddata.h.

178  {
179  if (o.d != d) {
180  if (o.d)
181  o.d->ref.ref();
182  T *old = d;
183  d = o.d;
184  if (old && !old->ref.deref())
185  delete old;
186  }
187  return *this;
188  }
QExplicitlySharedDataPointer& operator= ( T *  o)
inline

Definition at line 189 of file qshareddata.h.

189  {
190  if (o != d) {
191  if (o)
192  o->ref.ref();
193  T *old = d;
194  d = o;
195  if (old && !old->ref.deref())
196  delete old;
197  }
198  return *this;
199  }
bool operator! ( void  ) const
inline

Definition at line 206 of file qshareddata.h.

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

Definition at line 208 of file qshareddata.h.

209  { 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 241 of file qshareddata.h.

242 {
243  return new T(*d);
244 }

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