QtCore/qsharedpointer_impl.h File Reference

qsharedpointer_impl.h File Reference
#include <new>
#include <QtCore/qatomic.h>
#include <QtCore/qobject.h>

Classes

class  QWeakPointer< T >
 
class  QSharedPointer< T >
 
class  InternalRefCount< T >
 
class  ExternalRefCount< T >
 
struct  RemovePointer< T >
 
struct  RemovePointer< T * >
 
struct  RemovePointer< QSharedPointer< T > >
 
struct  RemovePointer< QWeakPointer< T > >
 
class  Basic< T >
 
struct  ExternalRefCountData
 
struct  ExternalRefCountWithDestroyFn
 
struct  ExternalRefCountWithCustomDeleter< T, Deleter >
 
struct  ExternalRefCountWithCustomDeleter< T, Deleter >::CustomDeleter
 
struct  ExternalRefCountWithContiguousData< T >
 
class  ExternalRefCount< T >
 
class  QSharedPointer< T >
 
class  QWeakPointer< T >
 

Namespaces

 QtSharedPointer
 
 std
 

Macros

#define QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X)    qt_sharedpointer_cast_check<T>(static_cast<X *>(0))
 

Functions

template<typename T >
QT_BEGIN_HEADER QT_BEGIN_NAMESPACE void qt_sharedpointer_cast_check (T *)
 
template<class X , class T >
QSharedPointer< X > qSharedPointerCast (const QSharedPointer< T > &ptr)
 
template<class X , class T >
QSharedPointer< X > qSharedPointerDynamicCast (const QSharedPointer< T > &ptr)
 
template<class X , class T >
QSharedPointer< X > qSharedPointerConstCast (const QSharedPointer< T > &ptr)
 
template<class X , class T >
QSharedPointer< X > qSharedPointerObjectCast (const QSharedPointer< T > &ptr)
 
template<class X , class Y >
QSharedPointer< X > copyAndSetPointer (X *ptr, const QSharedPointer< Y > &src)
 
Q_CORE_EXPORT void internalSafetyCheckAdd2 (const void *, const volatile void *)
 
Q_CORE_EXPORT void internalSafetyCheckRemove2 (const void *)
 
template<class T , typename Klass , typename RetVal >
void executeDeleter (T *t, RetVal(Klass::*memberDeleter)())
 
template<class T , typename Deleter >
void executeDeleter (T *t, Deleter d)
 
template<class T >
void normalDeleter (T *t)
 
template<class T , class X >
bool operator== (const QSharedPointer< T > &ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
bool operator!= (const QSharedPointer< T > &ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
bool operator== (const QSharedPointer< T > &ptr1, const X *ptr2)
 
template<class T , class X >
bool operator== (const T *ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
bool operator!= (const QSharedPointer< T > &ptr1, const X *ptr2)
 
template<class T , class X >
bool operator!= (const T *ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
bool operator== (const QSharedPointer< T > &ptr1, const QWeakPointer< X > &ptr2)
 
template<class T , class X >
bool operator!= (const QSharedPointer< T > &ptr1, const QWeakPointer< X > &ptr2)
 
template<class T , class X >
Q_INLINE_TEMPLATE QSharedPointer< T >::difference_type operator- (const QSharedPointer< T > &ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
Q_INLINE_TEMPLATE QSharedPointer< T >::difference_type operator- (const QSharedPointer< T > &ptr1, X *ptr2)
 
template<class T , class X >
Q_INLINE_TEMPLATE QSharedPointer< X >::difference_type operator- (T *ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
Q_INLINE_TEMPLATE bool operator< (const QSharedPointer< T > &ptr1, const QSharedPointer< X > &ptr2)
 
template<class T , class X >
Q_INLINE_TEMPLATE bool operator< (const QSharedPointer< T > &ptr1, X *ptr2)
 
template<class T , class X >
Q_INLINE_TEMPLATE bool operator< (T *ptr1, const QSharedPointer< X > &ptr2)
 
template<class T >
uint qHash (const T *key)
 
template<class T >
Q_INLINE_TEMPLATE uint qHash (const QSharedPointer< T > &ptr)
 
template<class T >
void qSwap (QSharedPointer< T > &p1, QSharedPointer< T > &p2)
 
template<class T >
void swap (QT_PREPEND_NAMESPACE(QSharedPointer)< T > &p1, QT_PREPEND_NAMESPACE(QSharedPointer)< T > &p2)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > copyAndSetPointer (X *ptr, const QSharedPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerCast (const QSharedPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerCast (const QWeakPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerDynamicCast (const QSharedPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerDynamicCast (const QWeakPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerConstCast (const QSharedPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerConstCast (const QWeakPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QWeakPointer< X > qWeakPointerCast (const QSharedPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerObjectCast (const QSharedPointer< T > &src)
 
template<class X , class T >
Q_INLINE_TEMPLATE QSharedPointer< X > qSharedPointerObjectCast (const QWeakPointer< T > &src)
 
template<class X , class T >
QSharedPointer< typename QtSharedPointer::RemovePointer< X >::Type > qobject_cast (const QSharedPointer< T > &src)
 
template<class X , class T >
QSharedPointer< typename QtSharedPointer::RemovePointer< X >::Type > qobject_cast (const QWeakPointer< T > &src)
 
template<typename T >
 Q_DECLARE_TYPEINFO_BODY (QWeakPointer< T >, Q_MOVABLE_TYPE)
 
template<typename T >
 Q_DECLARE_TYPEINFO_BODY (QSharedPointer< T >, Q_MOVABLE_TYPE)
 

Macro Definition Documentation

#define QSHAREDPOINTER_VERIFY_AUTO_CAST (   T,
 
)    qt_sharedpointer_cast_check<T>(static_cast<X *>(0))

Definition at line 81 of file qsharedpointer_impl.h.

Function Documentation

QT_BEGIN_HEADER QT_BEGIN_NAMESPACE void qt_sharedpointer_cast_check ( T *  )
inline

Definition at line 80 of file qsharedpointer_impl.h.

80 { }
QSharedPointer<X> qSharedPointerCast ( const QSharedPointer< T > &  ptr)

Definition at line 820 of file qsharedpointer_impl.h.

821 {
822  register X *ptr = static_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
824 }
GLuint src
Definition: GLee.h:7190
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
QSharedPointer<X> qSharedPointerDynamicCast ( const QSharedPointer< T > &  ptr)

Definition at line 832 of file qsharedpointer_impl.h.

833 {
834  register X *ptr = dynamic_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
835  if (!ptr)
836  return QSharedPointer<X>();
838 }
GLuint src
Definition: GLee.h:7190
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
QSharedPointer<X> qSharedPointerConstCast ( const QSharedPointer< T > &  ptr)

Definition at line 846 of file qsharedpointer_impl.h.

847 {
848  register X *ptr = const_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
850 }
GLuint src
Definition: GLee.h:7190
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
QSharedPointer<X> qSharedPointerObjectCast ( const QSharedPointer< T > &  ptr)

Definition at line 866 of file qsharedpointer_impl.h.

867 {
868  register X *ptr = qobject_cast<X *>(src.data());
870 }
QSharedPointer< typename QtSharedPointer::RemovePointer< X >::Type > qobject_cast(const QSharedPointer< T > &src)
GLuint src
Definition: GLee.h:7190
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
bool operator== ( const QSharedPointer< T > &  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 694 of file qsharedpointer_impl.h.

695 {
696  return ptr1.data() == ptr2.data();
697 }
bool operator!= ( const QSharedPointer< T > &  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 699 of file qsharedpointer_impl.h.

700 {
701  return ptr1.data() != ptr2.data();
702 }
bool operator== ( const QSharedPointer< T > &  ptr1,
const X *  ptr2 
)

Definition at line 705 of file qsharedpointer_impl.h.

706 {
707  return ptr1.data() == ptr2;
708 }
bool operator== ( const T *  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 710 of file qsharedpointer_impl.h.

711 {
712  return ptr1 == ptr2.data();
713 }
bool operator!= ( const QSharedPointer< T > &  ptr1,
const X *  ptr2 
)

Definition at line 715 of file qsharedpointer_impl.h.

716 {
717  return !(ptr1 == ptr2);
718 }
bool operator!= ( const T *  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 720 of file qsharedpointer_impl.h.

721 {
722  return !(ptr2 == ptr1);
723 }
bool operator== ( const QSharedPointer< T > &  ptr1,
const QWeakPointer< X > &  ptr2 
)

Definition at line 726 of file qsharedpointer_impl.h.

727 {
728  return ptr2 == ptr1;
729 }
bool operator!= ( const QSharedPointer< T > &  ptr1,
const QWeakPointer< X > &  ptr2 
)

Definition at line 731 of file qsharedpointer_impl.h.

732 {
733  return ptr2 != ptr1;
734 }
Q_INLINE_TEMPLATE QSharedPointer<T>::difference_type operator- ( const QSharedPointer< T > &  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 740 of file qsharedpointer_impl.h.

741 {
742  return ptr1.data() - ptr2.data();
743 }
Q_INLINE_TEMPLATE QSharedPointer<T>::difference_type operator- ( const QSharedPointer< T > &  ptr1,
X *  ptr2 
)

Definition at line 745 of file qsharedpointer_impl.h.

746 {
747  return ptr1.data() - ptr2;
748 }
Q_INLINE_TEMPLATE QSharedPointer<X>::difference_type operator- ( T *  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 750 of file qsharedpointer_impl.h.

751 {
752  return ptr1 - ptr2.data();
753 }
Q_INLINE_TEMPLATE bool operator< ( const QSharedPointer< T > &  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 759 of file qsharedpointer_impl.h.

760 {
761  return ptr1.data() < ptr2.data();
762 }
Q_INLINE_TEMPLATE bool operator< ( const QSharedPointer< T > &  ptr1,
X *  ptr2 
)

Definition at line 764 of file qsharedpointer_impl.h.

765 {
766  return ptr1.data() < ptr2;
767 }
Q_INLINE_TEMPLATE bool operator< ( T *  ptr1,
const QSharedPointer< X > &  ptr2 
)

Definition at line 769 of file qsharedpointer_impl.h.

770 {
771  return ptr1 < ptr2.data();
772 }
uint qHash ( const T *  key)
inline

Definition at line 97 of file qhash.h.

98 {
99  return qHash(reinterpret_cast<quintptr>(key));
100 }
uint qHash(char key)
Definition: qhash.h:62
Q_INLINE_TEMPLATE uint qHash ( const QSharedPointer< T > &  ptr)

Definition at line 779 of file qsharedpointer_impl.h.

780 {
781  return QT_PREPEND_NAMESPACE(qHash)<T>(ptr.data());
782 }
uint qHash(const T *key)
Definition: qhash.h:97
void qSwap ( QSharedPointer< T > &  p1,
QSharedPointer< T > &  p2 
)
inline

Definition at line 792 of file qsharedpointer_impl.h.

793 {
794  p1.swap(p2);
795 }
void swap(QSharedPointer &other)
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerCast ( const QSharedPointer< T > &  src)

Definition at line 820 of file qsharedpointer_impl.h.

821 {
822  register X *ptr = static_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
823  return QtSharedPointer::copyAndSetPointer(ptr, src);
824 }
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerCast ( const QWeakPointer< T > &  src)

Definition at line 826 of file qsharedpointer_impl.h.

827 {
828  return qSharedPointerCast<X, T>(src.toStrongRef());
829 }
QSharedPointer< T > toStrongRef() const
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast ( const QSharedPointer< T > &  src)

Definition at line 832 of file qsharedpointer_impl.h.

833 {
834  register X *ptr = dynamic_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
835  if (!ptr)
836  return QSharedPointer<X>();
837  return QtSharedPointer::copyAndSetPointer(ptr, src);
838 }
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast ( const QWeakPointer< T > &  src)

Definition at line 840 of file qsharedpointer_impl.h.

841 {
842  return qSharedPointerDynamicCast<X, T>(src.toStrongRef());
843 }
QSharedPointer< T > toStrongRef() const
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast ( const QSharedPointer< T > &  src)

Definition at line 846 of file qsharedpointer_impl.h.

847 {
848  register X *ptr = const_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
849  return QtSharedPointer::copyAndSetPointer(ptr, src);
850 }
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast ( const QWeakPointer< T > &  src)

Definition at line 852 of file qsharedpointer_impl.h.

853 {
854  return qSharedPointerConstCast<X, T>(src.toStrongRef());
855 }
QSharedPointer< T > toStrongRef() const
Q_INLINE_TEMPLATE QWeakPointer<X> qWeakPointerCast ( const QSharedPointer< T > &  src)

Definition at line 859 of file qsharedpointer_impl.h.

860 {
861  return qSharedPointerCast<X, T>(src).toWeakRef();
862 }
GLuint src
Definition: GLee.h:7190
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerObjectCast ( const QSharedPointer< T > &  src)

Definition at line 866 of file qsharedpointer_impl.h.

867 {
868  register X *ptr = qobject_cast<X *>(src.data());
869  return QtSharedPointer::copyAndSetPointer(ptr, src);
870 }
QSharedPointer< typename QtSharedPointer::RemovePointer< X >::Type > qobject_cast(const QSharedPointer< T > &src)
QSharedPointer< X > copyAndSetPointer(X *ptr, const QSharedPointer< Y > &src)
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerObjectCast ( const QWeakPointer< T > &  src)

Definition at line 872 of file qsharedpointer_impl.h.

873 {
874  return qSharedPointerObjectCast<X>(src.toStrongRef());
875 }
QSharedPointer< T > toStrongRef() const
QSharedPointer<typename QtSharedPointer::RemovePointer<X>::Type> qobject_cast ( const QSharedPointer< T > &  src)
inline

Definition at line 879 of file qsharedpointer_impl.h.

880 {
881  return qSharedPointerObjectCast<typename QtSharedPointer::RemovePointer<X>::Type, T>(src);
882 }
GLuint src
Definition: GLee.h:7190
QSharedPointer<typename QtSharedPointer::RemovePointer<X>::Type> qobject_cast ( const QWeakPointer< T > &  src)
inline

Definition at line 885 of file qsharedpointer_impl.h.

886 {
887  return qSharedPointerObjectCast<typename QtSharedPointer::RemovePointer<X>::Type, T>(src);
888 }
GLuint src
Definition: GLee.h:7190
Q_DECLARE_TYPEINFO_BODY ( QWeakPointer< T >  ,
Q_MOVABLE_TYPE   
)
Q_DECLARE_TYPEINFO_BODY ( QSharedPointer< T >  ,
Q_MOVABLE_TYPE   
)

Go to the source code of this file.