Public Types | Public Member Functions | Friends

QWeakPointer< T > Class Template Reference

Search for all occurrences

Detailed Description

template<class T>
class QWeakPointer< T >

Definition at line 534 of file qsharedpointer_impl.h.

#include <qsharedpointer_impl.h>

List of all members.

Public Types

typedef T  element_type
typedef T  value_type
typedef value_type pointer
typedef const value_type const_pointer
typedef value_type reference
typedef const value_type const_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 >
QWeakPointer operator= (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

class  QSharedPointer

Member Typedef Documentation

typedef T element_type
typedef T value_type
typedef value_type* pointer
typedef const value_type* const_pointer
typedef const value_type& const_reference
typedef qptrdiff difference_type

Constructor & Destructor Documentation

QWeakPointer ( ) [inline]

Definition at line 559 of file qsharedpointer_impl.h.

: d(0), value(0) { }
~QWeakPointer ( ) [inline]

Definition at line 560 of file qsharedpointer_impl.h.

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

Definition at line 565 of file qsharedpointer_impl.h.

                                : d(ptr ? d->getAndRef(ptr) : 0), value(ptr)
    { }
QWeakPointer ( const QWeakPointer< T > &  o ) [inline]

Definition at line 572 of file qsharedpointer_impl.h.

                                                  : d(o.d), value(o.value)
    { if (d) d->weakref.ref(); }
QWeakPointer ( const QSharedPointer< T > &  o ) [inline]

Definition at line 580 of file qsharedpointer_impl.h.

                                                    : d(o.d), value(o.data())
    { if (d) d->weakref.ref();}
QWeakPointer ( const QWeakPointer< X > &  o ) [inline]

Definition at line 589 of file qsharedpointer_impl.h.

                                                  : d(0), value(0)
    { *this = o; }
QWeakPointer ( const QSharedPointer< X > &  o ) [inline]

Definition at line 610 of file qsharedpointer_impl.h.

                                                    : d(0), value(0)
    { *this = o; }

Member Function Documentation

bool isNull ( ) const [inline]

Definition at line 550 of file qsharedpointer_impl.h.

{ return d == 0 || d->strongref == 0 || value == 0; }
operator RestrictedBool ( ) const [inline]

Definition at line 552 of file qsharedpointer_impl.h.

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

Definition at line 556 of file qsharedpointer_impl.h.

{ return isNull(); }
T* data ( ) const [inline]

Definition at line 557 of file qsharedpointer_impl.h.

{ return d == 0 || d->strongref == 0 ? 0 : value; }
QWeakPointer& operator= ( X *  ptr ) [inline]

Definition at line 569 of file qsharedpointer_impl.h.

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

Definition at line 574 of file qsharedpointer_impl.h.

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

Definition at line 582 of file qsharedpointer_impl.h.

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

Definition at line 593 of file qsharedpointer_impl.h.

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

Definition at line 602 of file qsharedpointer_impl.h.

    { return d == o.d && value == static_cast<const T *>(o.value); }
bool operator!= ( const QWeakPointer< X > &  o ) const [inline]

Definition at line 606 of file qsharedpointer_impl.h.

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

Definition at line 614 of file qsharedpointer_impl.h.

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

Definition at line 622 of file qsharedpointer_impl.h.

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

Definition at line 626 of file qsharedpointer_impl.h.

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

Definition at line 629 of file qsharedpointer_impl.h.

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

Definition at line 631 of file qsharedpointer_impl.h.

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

Friends And Related Function Documentation

friend class QSharedPointer [friend]

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