![]() |
CopperSpice API
2.0.0
|
Represents a pointer to an implicitly shared object. More...
Public Typedefs | |
using | pointer = T * |
using | Type = T |
Public Methods | |
QSharedDataPointer () | |
QSharedDataPointer (const QSharedDataPointer< T > &other) | |
QSharedDataPointer (QSharedDataPointer &&other) | |
QSharedDataPointer (T *data) | |
~QSharedDataPointer () | |
const T * | constData () const |
T * | data () |
const T * | data () const |
void | detach () |
operator const T * () const | |
operator T * () | |
bool | operator! () const |
bool | operator!= (const QSharedDataPointer< T > &other) const |
T & | operator* () |
const T & | operator* () const |
T * | operator-> () |
const T * | operator-> () const |
QSharedDataPointer< T > & | operator= (const QSharedDataPointer< T > &other) |
QSharedDataPointer< T > & | operator= (QSharedDataPointer< T > &&other) |
QSharedDataPointer & | operator= (T *other) |
bool | operator== (const QSharedDataPointer< T > &other) const |
void | swap (QSharedDataPointer &other) |
Protected Methods | |
T * | clone () |
The QSharedDataPointer class represents a pointer to an implicitly shared object. QSharedDataPointer<T> simplifies the process of writing your own implicitly shared classes. QSharedDataPointer implements thread safe reference counting.
This example shows how to implement a class which uses copy on write. Please be advised that implementing this type of class has significant drawbacks and is not recommended.
QSharedDataPointer< T >::pointer |
Typedef for T*.
QSharedDataPointer< T >::Type |
Typedef for T.
|
inline |
Constructs a QSharedDataPointer initialized with a null data pointer.
|
inlineexplicit |
Constructs a QSharedDataPointer with the data pointer set to data and increments the reference count.
|
inline |
Copy constructs a new QSharedDataPointer from other.
|
inline |
Move constructs a new QSharedDataPointer from other.
|
inline |
Decrements the reference count of the shared data object. If the reference count becomes 0 the object is deleted.
|
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. This method uses operator new and calls the copy constructor of the type T.
This method is provided so that you may support "virtual copy constructors" for your own types.
In order to do so declare a template specialization of this method for your own type. In this example, the template specialization for the clone() method calls the EmployeeData::clone() virtual method. A class derived from EmployeeData could override that method and return the proper polymorphic type.
|
inline |
|
inline |
Returns a pointer to the shared data object. This method calls detach().
|
inline |
Returns a pointer to the shared data object. This method does not call detach().
|
inline |
If the shared data object reference count is greater than 1, this method creates a deep copy of the shared data object and sets the current QSharedDataPointer to the copy.
|
inline |
Returns a pointer to the shared data object. This method does not call detach().
|
inline |
Returns a pointer to the shared data object. This method calls detach().
|
inline |
Returns true if the current QSharedDataPointer is null.
bool QSharedDataPointer< T >::operator!= | ( | const QSharedDataPointer< T > & | other | ) | const |
Returns true if this QSharedDataPointer is not equal to other, otherwise returns false.
|
inline |
Returns a reference to the object. This method calls detach().
|
inline |
Returns a const reference to the object. This method does not call detach().
|
inline |
Returns a pointer to the object. This method calls detach().
|
inline |
Returns a const pointer to the object. This method does not call detach().
|
inline |
Copy assigns from other and returns a reference to this object.
The new reference count is incremented and the old reference count is decremented. If the reference count of the old shared data object becomes 0 then the old shared data object is deleted.
|
inline |
Move assigns from other and returns a reference to this object.
|
inline |
Sets the current QSharedDataPointer 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 then the old shared data object is deleted.
|
inline |
Returns true if this QSharedDataPointer is equal to other, otherwise returns false.
|
inline |
Swap this instance's shared data pointer with the shared data pointer in other.