QWeakPointer< T > Class Template Reference

QWeakPointer< T > Class Template Reference

#include <qsharedpointer_impl.h>

Class Description

template<class T>
class QWeakPointer< T >

Definition at line 88 of file qsharedpointer_impl.h.

Public Types

typedef T element_type
 
typedef T value_type
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef qptrdiff difference_type
 

Public Member Functions

bool isNull () const
 
 operator RestrictedBool () const
 
bool operator! () const
 
T * data () const
 
 QWeakPointer ()
 
 ~QWeakPointer ()
 
template<class X >
 QWeakPointer (X *ptr)
 
template<class X >
QWeakPointeroperator= (X *ptr)
 
 QWeakPointer (const QWeakPointer< T > &o)
 
QWeakPointer< T > & operator= (const QWeakPointer< T > &o)
 
 QWeakPointer (const QSharedPointer< T > &o)
 
QWeakPointer< T > & operator= (const QSharedPointer< T > &o)
 
template<class X >
 QWeakPointer (const QWeakPointer< X > &o)
 
template<class X >
QWeakPointer< T > & operator= (const QWeakPointer< X > &o)
 
template<class X >
bool operator== (const QWeakPointer< X > &o) const
 
template<class X >
bool operator!= (const QWeakPointer< X > &o) const
 
template<class X >
 QWeakPointer (const QSharedPointer< X > &o)
 
template<class X >
QWeakPointer< T > & operator= (const QSharedPointer< X > &o)
 
template<class X >
bool operator== (const QSharedPointer< X > &o) const
 
template<class X >
bool operator!= (const QSharedPointer< X > &o) const
 
void clear ()
 
QSharedPointer< T > toStrongRef () const
 

Friends

template<class X >
class QSharedPointer
 

Member Typedef Documentation

typedef T element_type

Definition at line 572 of file qsharedpointer_impl.h.

typedef T value_type

Definition at line 573 of file qsharedpointer_impl.h.

typedef value_type* pointer

Definition at line 574 of file qsharedpointer_impl.h.

typedef const value_type* const_pointer

Definition at line 575 of file qsharedpointer_impl.h.

Definition at line 576 of file qsharedpointer_impl.h.

typedef const value_type& const_reference

Definition at line 577 of file qsharedpointer_impl.h.

typedef qptrdiff difference_type

Definition at line 578 of file qsharedpointer_impl.h.

Constructor & Destructor Documentation

QWeakPointer ( )
inline

Definition at line 589 of file qsharedpointer_impl.h.

589 : d(0), value(0) { }
GLsizei const GLfloat * value
Definition: GLee.h:1742
~QWeakPointer ( )
inline

Definition at line 590 of file qsharedpointer_impl.h.

590 { if (d && !d->weakref.deref()) delete d; }
QWeakPointer ( X *  ptr)
inline

Definition at line 595 of file qsharedpointer_impl.h.

595  : d(ptr ? Data::getAndRef(ptr) : 0), value(ptr)
596  { }
GLsizei const GLfloat * value
Definition: GLee.h:1742
static Q_CORE_EXPORT ExternalRefCountData * getAndRef(const QObject *)
QWeakPointer ( const QWeakPointer< T > &  o)
inline

Definition at line 602 of file qsharedpointer_impl.h.

602  : d(o.d), value(o.value)
603  { if (d) d->weakref.ref(); }
GLsizei const GLfloat * value
Definition: GLee.h:1742
QWeakPointer ( const QSharedPointer< T > &  o)
inline

Definition at line 610 of file qsharedpointer_impl.h.

610  : d(o.d), value(o.data())
611  { if (d) d->weakref.ref();}
GLsizei const GLfloat * value
Definition: GLee.h:1742
QWeakPointer ( const QWeakPointer< X > &  o)
inline

Definition at line 619 of file qsharedpointer_impl.h.

619  : d(0), value(0)
620  { *this = o; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
QWeakPointer ( const QSharedPointer< X > &  o)
inline

Definition at line 640 of file qsharedpointer_impl.h.

640  : d(0), value(0)
641  { *this = o; }
GLsizei const GLfloat * value
Definition: GLee.h:1742

Member Function Documentation

bool isNull ( ) const
inline

Definition at line 580 of file qsharedpointer_impl.h.

580 { return d == 0 || d->strongref == 0 || value == 0; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
operator RestrictedBool ( ) const
inline

Definition at line 582 of file qsharedpointer_impl.h.

582 { return isNull() ? 0 : &QWeakPointer::value; }
bool isNull() const
bool operator! ( void  ) const
inline

Definition at line 586 of file qsharedpointer_impl.h.

586 { return isNull(); }
bool isNull() const
T* data ( ) const
inline

Definition at line 587 of file qsharedpointer_impl.h.

587 { return d == 0 || d->strongref == 0 ? 0 : value; }
GLsizei const GLfloat * value
Definition: GLee.h:1742
QWeakPointer& operator= ( X *  ptr)
inline

Definition at line 599 of file qsharedpointer_impl.h.

600  { return *this = QWeakPointer(ptr); }
QWeakPointer<T>& operator= ( const QWeakPointer< T > &  o)
inline

Definition at line 604 of file qsharedpointer_impl.h.

605  {
606  internalSet(o.d, o.value);
607  return *this;
608  }
QWeakPointer<T>& operator= ( const QSharedPointer< T > &  o)
inline

Definition at line 612 of file qsharedpointer_impl.h.

613  {
614  internalSet(o.d, o.value);
615  return *this;
616  }
QWeakPointer<T>& operator= ( const QWeakPointer< X > &  o)
inline

Definition at line 623 of file qsharedpointer_impl.h.

624  {
625  // conversion between X and T could require access to the virtual table
626  // so force the operation to go through QSharedPointer
627  *this = o.toStrongRef();
628  return *this;
629  }
QSharedPointer< T > toStrongRef() const
bool operator== ( const QWeakPointer< X > &  o) const
inline

Definition at line 632 of file qsharedpointer_impl.h.

633  { return d == o.d && value == static_cast<const T *>(o.value); }
GLsizei const GLfloat * value
Definition: GLee.h:1742
bool operator!= ( const QWeakPointer< X > &  o) const
inline

Definition at line 636 of file qsharedpointer_impl.h.

637  { return !(*this == o); }
QWeakPointer<T>& operator= ( const QSharedPointer< X > &  o)
inline

Definition at line 644 of file qsharedpointer_impl.h.

645  {
646  QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X); // if you get an error in this line, the cast is invalid
647  internalSet(o.d, o.data());
648  return *this;
649  }
#define QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X)
bool operator== ( const QSharedPointer< X > &  o) const
inline

Definition at line 652 of file qsharedpointer_impl.h.

653  { return d == o.d; }
bool operator!= ( const QSharedPointer< X > &  o) const
inline

Definition at line 656 of file qsharedpointer_impl.h.

657  { return !(*this == o); }
void clear ( )
inline

Definition at line 659 of file qsharedpointer_impl.h.

659 { *this = QWeakPointer<T>(); }
QSharedPointer<T> toStrongRef ( ) const
inline

Definition at line 661 of file qsharedpointer_impl.h.

661 { return QSharedPointer<T>(*this); }

Friends And Related Function Documentation

friend class QSharedPointer
friend

Definition at line 672 of file qsharedpointer_impl.h.


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