Home · Modules · All Classes · All Namespaces
Public Member Functions | Static Public Member Functions | List of all members
Tp::SharedPtr< T > Class Template Reference

The SharedPtr class is a pointer to an explicitly shared object. More...

#include <TelepathyQt/SharedPtr>

Public Member Functions

 SharedPtr ()
 
 SharedPtr (T *d)
 
template<typename Subclass >
 SharedPtr (const SharedPtr< Subclass > &o)
 
 SharedPtr (const SharedPtr< T > &o)
 
 SharedPtr (const WeakPtr< T > &o)
 
 ~SharedPtr ()
 
void reset ()
 
T * data () const
 
const T * constData () const
 
T * operator-> ()
 
T * operator-> () const
 
bool isNull () const
 
bool operator! () const
 
 operator UnspecifiedBoolType () const
 
bool operator== (const SharedPtr< T > &o) const
 
bool operator!= (const SharedPtr< T > &o) const
 
bool operator== (const T *ptr) const
 
bool operator!= (const T *ptr) const
 
SharedPtr< T > & operator= (const SharedPtr< T > &o)
 
void swap (SharedPtr< T > &o)
 

Static Public Member Functions

template<class X >
static SharedPtr< T > staticCast (const SharedPtr< X > &src)
 
template<class X >
static SharedPtr< T > dynamicCast (const SharedPtr< X > &src)
 
template<class X >
static SharedPtr< T > constCast (const SharedPtr< X > &src)
 
template<class X >
static SharedPtr< T > qObjectCast (const SharedPtr< X > &src)
 

Detailed Description

template<class T>
class Tp::SharedPtr< T >

The SharedPtr class is a pointer to an explicitly shared object.

Note that from Telepathy-Qt >= 0.9.0, Tp::SharedPtr cannot be constructed from a QWeakPointer as the conversion from a QWeakPointer to a Tp::SharedPtr can't be made thread-safe. Tp::WeakPtr is reintroduced as a weak pointer class safely promoteable to a Tp::SharedPtr.

See Shared Pointer Usage

Constructor & Destructor Documentation

◆ SharedPtr() [1/5]

template<class T>
Tp::SharedPtr< T >::SharedPtr ( )
inline

◆ SharedPtr() [2/5]

template<class T>
Tp::SharedPtr< T >::SharedPtr ( T *  d)
inlineexplicit

◆ SharedPtr() [3/5]

template<class T>
template<typename Subclass >
Tp::SharedPtr< T >::SharedPtr ( const SharedPtr< Subclass > &  o)
inline

◆ SharedPtr() [4/5]

template<class T>
Tp::SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  o)
inline

◆ SharedPtr() [5/5]

template<class T>
Tp::SharedPtr< T >::SharedPtr ( const WeakPtr< T > &  o)
inlineexplicit

◆ ~SharedPtr()

template<class T>
Tp::SharedPtr< T >::~SharedPtr ( )
inline

Member Function Documentation

◆ reset()

template<class T>
void Tp::SharedPtr< T >::reset ( )
inline

◆ data()

template<class T>
T* Tp::SharedPtr< T >::data ( ) const
inline

◆ constData()

template<class T>
const T* Tp::SharedPtr< T >::constData ( ) const
inline

◆ operator->() [1/2]

template<class T>
T* Tp::SharedPtr< T >::operator-> ( )
inline

◆ operator->() [2/2]

template<class T>
T* Tp::SharedPtr< T >::operator-> ( ) const
inline

◆ isNull()

template<class T>
bool Tp::SharedPtr< T >::isNull ( ) const
inline

◆ operator!()

template<class T>
bool Tp::SharedPtr< T >::operator! ( ) const
inline

◆ operator UnspecifiedBoolType()

template<class T>
Tp::SharedPtr< T >::operator UnspecifiedBoolType ( ) const
inline

◆ operator==() [1/2]

template<class T>
bool Tp::SharedPtr< T >::operator== ( const SharedPtr< T > &  o) const
inline

◆ operator!=() [1/2]

template<class T>
bool Tp::SharedPtr< T >::operator!= ( const SharedPtr< T > &  o) const
inline

◆ operator==() [2/2]

template<class T>
bool Tp::SharedPtr< T >::operator== ( const T *  ptr) const
inline

◆ operator!=() [2/2]

template<class T>
bool Tp::SharedPtr< T >::operator!= ( const T *  ptr) const
inline

◆ operator=()

template<class T>
SharedPtr<T>& Tp::SharedPtr< T >::operator= ( const SharedPtr< T > &  o)
inline

◆ swap()

template<class T>
void Tp::SharedPtr< T >::swap ( SharedPtr< T > &  o)
inline

◆ staticCast()

template<class T>
template<class X >
static SharedPtr<T> Tp::SharedPtr< T >::staticCast ( const SharedPtr< X > &  src)
inlinestatic

◆ dynamicCast()

template<class T>
template<class X >
static SharedPtr< T > Tp::SharedPtr< T >::dynamicCast ( const SharedPtr< X > &  src)
inlinestatic

Casts the pointer given by src to a pointer pointing to an object of type T. The cast will succeed if the C++ runtime type identification mechanism considers the type T to be the actual runtime type of the object pointed to by src or one of its (possibly indirect) parent classes. Otherwise, a null pointer is returned.

Note that this also allows down-casting a baseclass pointer to a subclass pointer.

This cast method should not be used for QObject-derived classes, as Qt provides a more portable and efficient type identification mechanism, which is used by qObjectCast().

This cast method requires the C++ dynamic runtime type identification facility to be enabled (which might be disabled by eg. the -fno-rtti flag of the GNU G++ compiler).

◆ constCast()

template<class T>
template<class X >
static SharedPtr<T> Tp::SharedPtr< T >::constCast ( const SharedPtr< X > &  src)
inlinestatic

◆ qObjectCast()

template<class T>
template<class X >
static SharedPtr< T > Tp::SharedPtr< T >::qObjectCast ( const SharedPtr< X > &  src)
inlinestatic

Casts the pointer given by src to a pointer pointing to an object of type T. The cast will succeed if the Qt runtime type identification mechanism considers the type T to be the actual runtime type of the object pointed to by src or one of its (possibly indirect) parent classes. Otherwise, a null pointer is returned.

Note that this also allows down-casting a baseclass pointer to a subclass pointer.

This cast method MUST not be used for classes not derived from QObject. However, dynamicCast() provides the same semantics for all classes, provided the C++ runtime type identification facility is enabled. This method, on the other hand, doesn't require the standard C++ facility and is probably also faster for the types it can be used with.