A smart pointer class ensuring the Qt reference counting for automatic memory management. QtPtr is a template-based smart pointer class that ensures Qt's reference counting manages the lifetime of a dynamically allocated object. When the parent owning an object is destroyed or reset, the managed object is automatically deleted. Additionally, when the observed object is destructed, the object observing will turn null.
More...
|
| | QtPtr (const QtPtr &other) |
| | Copy constructor that fully initiaises the object using the supplied object as its data source.
|
| | QtPtr (const UniqueQtPtr< ObjectType > &observe) |
| | Constructs a QtPtr that observes a given UniqueQtPtr object.
|
| | QtPtr (ObjectType *const observe=nullptr) |
| | Constructs a QtPtr that observes a given Qt object.
|
| | QtPtr (QtPtr &&other) noexcept |
| | Move constructor that fully initiaises the object by taking the supplied object as its data source.
|
| | ~QtPtr () |
| | Disconnects the Qt connection associated with the pointer if the observed object is derived from QObject.
|
| QtPtr & | operator= (const QtPtr &other) |
| | Copy assignment for the current instance using the supplied object as its data source.
|
| QtPtr & | operator= (QtPtr &&other) noexcept |
| | Move assignment for the current instance taking the supplied object as its data source.
|
| UniqueQtPtr< ObjectType > | releaseUnique () |
| | Releases the ownership of the Qt object.
|
| | ObserverPtr (ObjectType *const observe=nullptr) |
| | Full initialisation constructor for observing a naked pointer.
|
| | ~ObserverPtr ()=default |
| ObjectType * | get () const noexcept |
| | An accessor to the underlying pointer being observed.
|
| | operator bool () const noexcept |
| | Determines if this object is observing a pointer.
|
| void | operator delete (void *)=delete |
| | operator ObjectType * () const noexcept |
| | Conversion operator to the underlying pointer being observed.
|
| bool | operator!= (const std::nullptr_t) const |
| | Inequality operator for testing if this object points to null.
|
| ObjectType & | operator* () |
| | Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null.
|
| ObjectType * | operator-> () |
| | Dereference pointer to the observed pointer. The behaviour is undefined if the observed pointer is null.
|
| bool | operator< (const ObjectType *observed) const |
| | Less-than operator for testing if the address observed by this object appears before another specified naked pointer's address.
|
| ObserverPtr & | operator= (const ObserverPtr &)=default |
| bool | operator== (const std::nullptr_t) const |
| | Equality operator for testing if this object points to null.
|
template<typename ObjectType>
class drn::foundation::QtPtr< ObjectType >
A smart pointer class ensuring the Qt reference counting for automatic memory management. QtPtr is a template-based smart pointer class that ensures Qt's reference counting manages the lifetime of a dynamically allocated object. When the parent owning an object is destroyed or reset, the managed object is automatically deleted. Additionally, when the observed object is destructed, the object observing will turn null.
This is similar in nature to the QPointer, but with the addition of allowing non-QObject derived Qt objects to be stored in the pointer.
- Template Parameters
-
| ObjectType | The type of the object stored. |