QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
21 #ifndef QOBJECTUNIQUEPTR_H
22 #define QOBJECTUNIQUEPTR_H
27 #include <qtypeinfo.h>
42 Q_STATIC_ASSERT_X( !std::is_pointer<T>::value,
"QObjectUniquePtr's template type must not be a pointer type" );
50 struct TypeSelector<const U>
52 typedef const QObject Type;
54 typedef typename TypeSelector<T>::Type QObjectType;
55 QPointer<QObjectType> mPtr;
85 mPtr.swap( other.mPtr );
90 mPtr.assign(
static_cast<QObjectType *
>( p ) );
99 return static_cast<T *
>( mPtr.data() );
107 return static_cast<T *
>( mPtr.data() );
129 inline operator T *()
const
139 return mPtr.isNull();
147 inline operator bool()
const
149 return !mPtr.isNull();
166 T *p = qobject_cast<T *>( mPtr.data() );
187 return o == p.operator->();
193 return p.operator->() == o;
199 return o == p.operator->();
205 return p.operator->() == o;
211 return p1.operator->() == p2.operator->();
217 return o != p.operator->();
223 return p.operator->() != o;
229 return o != p.operator->();
235 return p.operator->() != o;
241 return p1.operator->() != p2.operator->() ;
248 return QObjectUniquePtr<T>( qobject_cast<T *>( QtSharedPointer::weakPointerFromVariant_internal( variant ).data() ) );
251 #endif // QOBJECTUNIQUEPTR_H
void swap(QObjectUniquePtr &other)
Swaps the pointer managed by this instance with the pointer managed by other.
void reset(T *p=nullptr)
Will reset the managed pointer to p.
bool operator!=(const T *o, const QObjectUniquePtr< T > &p)
void clear()
Clears the pointer.
bool operator==(const T *o, const QObjectUniquePtr< T > &p)
T * operator->() const
Returns a raw pointer to the managed QObject.
QObjectUniquePtr(T *p)
Takes a new QObjectUniquePtr and assigned p to it.
T * release()
Clears the pointer and returns it.
QObjectUniquePtr< T > & operator=(T *p)
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
~QObjectUniquePtr()
Will delete the contained QObject if it still exists.
T * data() const
Returns the raw pointer to the managed QObject.
QObjectUniquePtr< T > QObjectUniquePtrFromVariant(const QVariant &variant)
Q_DECLARE_TYPEINFO_BODY(QObjectUniquePtr< T >, Q_MOVABLE_TYPE)
T * get() const
Returns the raw pointer to the managed QObject.
QObjectUniquePtr()
Creates a new empty QObjectUniquePtr.
T & operator*() const
Dereferences the managed QObject.
bool isNull() const
Checks if the managed pointer is nullptr.