DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::foundation::UniqueQtPtr< ObjectType > Class Template Reference

A representation of a Qt object that is not handled by the usual Qt memory pattern. When the Qt object derives from a QObject, its deletion is handled on the event loop else it’s deleted immediately upon destruction. More...

#include <QtMemory.hpp>

Inheritance diagram for drn::foundation::UniqueQtPtr< ObjectType >:
Collaboration diagram for drn::foundation::UniqueQtPtr< ObjectType >:

Public Member Functions

 UniqueQtPtr (ObjectType *const obj=nullptr)
 Constructs an object to manage the given Qt object.
 
 UniqueQtPtr (std::nullptr_t)
 Constructs an object with a nullptr, initialising it to manage no object. This is useful when you need to explicitly initialise a pointer to a null state, ensuring that it does not point to any Qt object initially.
 
bool operator!= (std::nullptr_t) const noexcept
 Inequality operator for checking null.
 
bool operator== (std::nullptr_t) const noexcept
 Equality operator for checking null.
 

Detailed Description

template<typename ObjectType>
class drn::foundation::UniqueQtPtr< ObjectType >

A representation of a Qt object that is not handled by the usual Qt memory pattern. When the Qt object derives from a QObject, its deletion is handled on the event loop else it’s deleted immediately upon destruction.

Template Parameters
ObjectTypeThe type of the object stored.

Constructor & Destructor Documentation

◆ UniqueQtPtr() [1/2]

template<typename ObjectType>
drn::foundation::UniqueQtPtr< ObjectType >::UniqueQtPtr ( ObjectType *const obj = nullptr)
explicit

Constructs an object to manage the given Qt object.

Precondition
The pointer to the Qt object to be managed cannot have a parent.
Parameters
objA pointer to the Qt object to be managed.
Here is the caller graph for this function:

◆ UniqueQtPtr() [2/2]

template<typename ObjectType>
drn::foundation::UniqueQtPtr< ObjectType >::UniqueQtPtr ( std::nullptr_t )

Constructs an object with a nullptr, initialising it to manage no object. This is useful when you need to explicitly initialise a pointer to a null state, ensuring that it does not point to any Qt object initially.

Here is the call graph for this function:

Member Function Documentation

◆ operator!=()

template<typename ObjectType>
bool drn::foundation::UniqueQtPtr< ObjectType >::operator!= ( std::nullptr_t ) const
noexcept

Inequality operator for checking null.

Returns
False when the pointer is null, true otherwise.

◆ operator==()

template<typename ObjectType>
bool drn::foundation::UniqueQtPtr< ObjectType >::operator== ( std::nullptr_t ) const
noexcept

Equality operator for checking null.

Returns
True when the pointer is null, false otherwise.