CopperSpice API  2.0.0
QExplicitlySharedDataPointer< T > Class Template Reference

The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object. More...

Public Typedefs

using pointer = T *
 
using Type = T
 

Public Methods

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

Protected Methods

T * clone ()
 

Detailed Description

template<typename T>
class QExplicitlySharedDataPointer< T >

The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object. This class implements thread-safe reference counting.

QExplicitlySharedDataPointer vs QSharedDataPointer

Except for one major difference QExplicitlySharedDataPointer is very similar to a QSharedDataPointer.

The methods in QExplicitlySharedDataPointer do not provide automatic copy on write functionality. Instead there is a detach() method which must be called when a copy is required.

If your application uses this class and calls detach() frequently, consider using QSharedDataPointer.

See also
QSharedData, QSharedDataPointer

Member Typedef Documentation

template<typename T >
QExplicitlySharedDataPointer< T >::pointer

Equivalent to T *.

template<typename T >
QExplicitlySharedDataPointer< T >::Type

Equivalent to T.

Constructor & Destructor Documentation

template<typename T >
QExplicitlySharedDataPointer< T >::QExplicitlySharedDataPointer ( )
inline

Constructs a QExplicitlySharedDataPointer initialized to a nullptr.

template<class T >
QExplicitlySharedDataPointer< T >::QExplicitlySharedDataPointer ( T *  data)
inlineexplicit

Constructs a QExplicitlySharedDataPointer which points to the given data and increments the reference count.

template<typename T >
QExplicitlySharedDataPointer< T >::QExplicitlySharedDataPointer ( const QExplicitlySharedDataPointer< T > &  other)
inline

Copy constructs a new QExplicitlySharedDataPointer from other. The reference count of the data is incremented.

template<typename T >
template<class X >
QExplicitlySharedDataPointer< T >::QExplicitlySharedDataPointer ( const QExplicitlySharedDataPointer< X > &  other)
inline

Copy constructs a new QExplicitlySharedDataPointer by statically casting other. The reference count of the data is incremented.

template<typename T >
QExplicitlySharedDataPointer< T >::QExplicitlySharedDataPointer ( QExplicitlySharedDataPointer< T > &&  other)
inline

Move constructs a new QExplicitlySharedDataPointer from other.

template<typename T >
QExplicitlySharedDataPointer< T >::~QExplicitlySharedDataPointer ( )
inline

Decrements the reference count of data. If the reference count becomes 0 the data is deleted.

Method Documentation

template<typename T >
T * QExplicitlySharedDataPointer< T >::clone ( )
inlineprotected

Creates and returns a deep copy of the current data. This method is called by detach() when the reference count is greater than 1 in order to create the new copy.

See also
QSharedDataPointer::clone()
template<typename T >
const T * QExplicitlySharedDataPointer< T >::constData ( ) const
inline

Returns a const pointer to the shared data object.

See also
data()
template<typename T >
T * QExplicitlySharedDataPointer< T >::data ( ) const
inline

Returns a pointer to the shared data object.

template<typename T >
void QExplicitlySharedDataPointer< T >::detach ( )
inline

If the data reference count is greater than 1, then this method creates a deep copy of the shared data and sets the current QExplicitlySharedDataPointer to point to the copy.

template<typename T >
QExplicitlySharedDataPointer< T >::operator bool ( ) const
inline

Returns true if data is not a nullptr.

template<typename T >
bool QExplicitlySharedDataPointer< T >::operator! ( ) const
inline

Returns true if data is a nullptr.

template<typename T >
template<class U >
bool QExplicitlySharedDataPointer< T >::operator!= ( const QExplicitlySharedDataPointer< U > &  other) const

Returns true if this QExplicitlySharedDataPointer is not equal to other, otherwise returns false.

template<typename T >
bool QExplicitlySharedDataPointer< T >::operator!= ( const T *  ptr) const

Returns true if this QExplicitlySharedDataPointer is not equal to ptr, otherwise returns false.

template<typename T >
T & QExplicitlySharedDataPointer< T >::operator* ( ) const
inline

Provides access to the data.

template<typename T >
T * QExplicitlySharedDataPointer< T >::operator-> ( )
inline

Provides access to the data.

template<typename T >
T * QExplicitlySharedDataPointer< T >::operator-> ( ) const
inline

Provides read only access to the data.

template<typename T >
QExplicitlySharedDataPointer< T > & QExplicitlySharedDataPointer< T >::operator= ( const QExplicitlySharedDataPointer< T > &  other)
inline

Assigns other to the current QSharedDataPointer and increments the reference count. The reference count of the old shared data object is decremented. If the reference count of the old shared data object becomes 0, the old shared data object is deleted.

template<typename T >
QExplicitlySharedDataPointer< T > & QExplicitlySharedDataPointer< T >::operator= ( QExplicitlySharedDataPointer< T > &&  other)
inline

Move assigns from other and returns a reference to this object.

template<typename T >
QExplicitlySharedDataPointer & QExplicitlySharedDataPointer< T >::operator= ( T *  other)
inline

Sets the current QExplicitlySharedDataPointer to other and increments the reference count. The reference count of the old shared data is decremented. If the reference count of the old shared data object becomes 0, the old shared data object is deleted.

template<typename T >
template<class U >
bool QExplicitlySharedDataPointer< T >::operator== ( const QExplicitlySharedDataPointer< U > &  other) const
inline

Returns true if this QExplicitlySharedDataPointer is equal to other, otherwise returns false.

template<typename T >
bool QExplicitlySharedDataPointer< T >::operator== ( const T *  ptr) const
inline

Returns true if this QExplicitlySharedDataPointer is equal to ptr, otherwise returns false.

template<typename T >
void QExplicitlySharedDataPointer< T >::reset ( )
inline

Resets the current QExplicitlySharedDataPointer to a nullptr. If the reference count becomes 0 the data will be destroyed.

template<typename T >
void QExplicitlySharedDataPointer< T >::swap ( QExplicitlySharedDataPointer< T > &  other)
inline

Swap this QExplicitlySharedDataPointer with other.