CopperSpice API  1.9.1
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
 
bool operator!= (const QExplicitlySharedDataPointer< T > &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)
 
bool operator== (const QExplicitlySharedDataPointer< T > &other) const
 
bool operator== (const T *ptr) const
 
void reset ()
 
void swap (QExplicitlySharedDataPointer &other)
 

Protected Methods

T * clone ()
 

Detailed Description

template<class T>
class QExplicitlySharedDataPointer< T >

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

This class makes writing your own explicitly shared classes easy. QExplicitlySharedDataPointer implements thread-safe reference counting, ensuring that adding QExplicitlySharedDataPointers to your classes will not make them stop being conditionally thread safe.

Except for one major difference, QExplicitlySharedDataPointer is very similar to QSharedDataPointer. The methods in QExplicitlySharedDataPointer do not provide automatic copy on write operations. There is a detach() method available which you will need to call in your code. If you use this class and calling detach() frequently, consider using QSharedDataPointer instead.

See also
QSharedData, QSharedDataPointer

Member Typedef Documentation

template<class T >
QExplicitlySharedDataPointer< T >::pointer

A typedef for T *.

template<class T >
QExplicitlySharedDataPointer< T >::Type

A typedef for T.

Constructor & Destructor Documentation

template<class 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<class 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<class 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<class T >
QExplicitlySharedDataPointer< T >::QExplicitlySharedDataPointer ( QExplicitlySharedDataPointer< T > &&  other)
inline

Move constructs a new QExplicitlySharedDataPointer from other.

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

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

Method Documentation

template<class 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<class T >
const T * QExplicitlySharedDataPointer< T >::constData ( ) const
inline

Returns a const pointer to the shared data object.

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

Returns a pointer to the shared data object.

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

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

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

Returns true if data is not a nullptr.

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

Returns true if data is a nullptr.

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

Returns true if other and this do not point to the same data.

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

Returns true if this does not point to the given ptr.

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

Provides access to the data.

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

Provides access to the data.

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

Provides read only access to the data.

template<class 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<class T >
QExplicitlySharedDataPointer< T > & QExplicitlySharedDataPointer< T >::operator= ( QExplicitlySharedDataPointer< T > &&  other)
inline

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

template<class 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<class T >
bool QExplicitlySharedDataPointer< T >::operator== ( const QExplicitlySharedDataPointer< T > &  other) const
inline

Returns true if this object points to the same object as other.

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

Returns true if this object points to the same object as ptr.

template<class 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<class T >
void QExplicitlySharedDataPointer< T >::swap ( QExplicitlySharedDataPointer< T > &  other)
inline

Swap this instance's explicitly shared data pointer with the explicitly shared data pointer in other.