java.lang.Object
io.qt.core.QScopedPointer<O>
- All Implemented Interfaces:
MetaTypeUtility.SmartPointer
,AutoCloseable
Java wrapper for Qt class QScopedPointer to be used inside a try-with-resource block.
Example:
try(var pointer = QScopedPointer.disposing(new QDialog())){
QDialog dialog = pointer.get();
dialog.exec();
}
// dialog is disposed
Alternatively, performAndDispose disposes a recource after calling a lambda expression:
QScopedPointer.performAndDispose(QDialog::exec, new QDialog());
-
Method Summary
Modifier and TypeMethodDescriptionstatic <O> QScopedPointer<O>
Creates a scoped pointer for the given object performing the given operation at cleanup.static <O> QScopedPointer<O>
Deprecated, for removal: This API element is subject to removal in a future version.void
close()
performs the cleanup operationdata()
Returns the object stored by this scoped pointerstatic <O extends QtObjectInterface>
QScopedPointer<O>disposing
(O data) Creates a scoped pointer for the given object performingQtObjectInterface.dispose()
at cleanup.static <O extends QObject>
QScopedPointer<O>disposingLater
(O data) Creates a scoped pointer for the given object performingQObject.disposeLater()
at cleanup.get()
boolean
isNull()
static <O> void
performAndCleanup
(Consumer<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.static <O,
R> R performAndCleanup
(Function<O, R> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.static <O> double
performAndCleanup
(ToDoubleFunction<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.static <O> int
performAndCleanup
(ToIntFunction<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.static <O> long
performAndCleanup
(ToLongFunction<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.static <O extends QtObjectInterface>
voidperformAndDispose
(Consumer<O> action, O data) Performs an action on a resource which will be disposes subsequently.static <O extends QtObjectInterface,
R>
RperformAndDispose
(Function<O, R> action, O data) Performs an action on a resource which will be disposes subsequently.static <O extends QtObjectInterface>
doubleperformAndDispose
(ToDoubleFunction<O> action, O data) Performs an action on a resource which will be disposes subsequently.static <O extends QtObjectInterface>
intperformAndDispose
(ToIntFunction<O> action, O data) Performs an action on a resource which will be disposes subsequently.static <O extends QtObjectInterface>
longperformAndDispose
(ToLongFunction<O> action, O data) Performs an action on a resource which will be disposes subsequently.static <O extends QObject>
voidperformAndDisposeLater
(Consumer<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.static <O extends QObject,
R>
RperformAndDisposeLater
(Function<O, R> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.static <O extends QObject>
doubleperformAndDisposeLater
(ToDoubleFunction<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.static <O extends QObject>
intperformAndDisposeLater
(ToIntFunction<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.static <O extends QObject>
longperformAndDisposeLater
(ToLongFunction<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.void
reset()
Overloaded function forreset(Object)
withother=null
.void
performs cleanup operation on the contained object and sets new reference.void
swap
(QScopedPointer<O> other) take()
Removes and returns the object stored by this scoped pointer without cleanup
-
Method Details
-
data
Returns the object stored by this scoped pointer
- Returns:
- data
-
get
- See Also:
-
take
Removes and returns the object stored by this scoped pointer without cleanup
- Returns:
- data
-
reset
performs cleanup operation on the contained object and sets new reference.
-
reset
Overloaded function forreset(Object)
withother=null
. -
isNull
-
swap
-
close
performs the cleanup operation- Specified by:
close
in interfaceAutoCloseable
-
disposing
Creates a scoped pointer for the given object performingQtObjectInterface.dispose()
at cleanup.- Parameters:
data
- the contained object- Returns:
- scoped pointer
-
disposingLater
Creates a scoped pointer for the given object performingQObject.disposeLater()
at cleanup.- Parameters:
data
- the contained object- Returns:
- scoped pointer
-
cleanup
@QtUninvokable @Deprecated(forRemoval=true) public static <O> QScopedPointer<O> cleanup(O data, Consumer<O> cleanup) Deprecated, for removal: This API element is subject to removal in a future version. -
cleanup
Creates a scoped pointer for the given object performing the given operation at cleanup.- Parameters:
cleanup
- operation performed at cleanupdata
- the contained object- Returns:
- scoped pointer
-
performAndDispose
@QtUninvokable public static <O extends QtObjectInterface> void performAndDispose(Consumer<O> action, O data) Performs an action on a resource which will be disposes subsequently.QScopedPointer.performAndDispose(QDialog::exec, new QDialog());
- Parameters:
action
- the actiondata
- the resource
-
performAndDisposeLater
@QtUninvokable public static <O extends QObject> void performAndDisposeLater(Consumer<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.QScopedPointer.performAndDispose(QDialog::exec, new QDialog());
- Parameters:
action
- the actiondata
- the resource
-
performAndCleanup
@QtUninvokable public static <O> void performAndCleanup(Consumer<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.QScopedPointer.performAndCleanup(object-> { ...//action }, object -> { object.cleanup(); }, new CustomObject() );
- Parameters:
action
- the actiondata
- the resource
-
performAndDispose
@QtUninvokable public static <O extends QtObjectInterface,R> R performAndDispose(Function<O, R> action, O data) Performs an action on a resource which will be disposes subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDisposeLater
@QtUninvokable public static <O extends QObject,R> R performAndDisposeLater(Function<O, R> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndCleanup
@QtUninvokable public static <O,R> R performAndCleanup(Function<O, R> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDispose
@QtUninvokable public static <O extends QtObjectInterface> int performAndDispose(ToIntFunction<O> action, O data) Performs an action on a resource which will be disposes subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDisposeLater
@QtUninvokable public static <O extends QObject> int performAndDisposeLater(ToIntFunction<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndCleanup
@QtUninvokable public static <O> int performAndCleanup(ToIntFunction<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDispose
@QtUninvokable public static <O extends QtObjectInterface> double performAndDispose(ToDoubleFunction<O> action, O data) Performs an action on a resource which will be disposes subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDisposeLater
@QtUninvokable public static <O extends QObject> double performAndDisposeLater(ToDoubleFunction<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndCleanup
@QtUninvokable public static <O> double performAndCleanup(ToDoubleFunction<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDispose
@QtUninvokable public static <O extends QtObjectInterface> long performAndDispose(ToLongFunction<O> action, O data) Performs an action on a resource which will be disposes subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndDisposeLater
@QtUninvokable public static <O extends QObject> long performAndDisposeLater(ToLongFunction<O> action, O data) Performs an action on aQObject
resource which will be calledQObject.disposeLater()
subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-
performAndCleanup
@QtUninvokable public static <O> long performAndCleanup(ToLongFunction<O> action, Consumer<O> cleanup, O data) Performs an action on a resource which will be cleaned up subsequently.- Parameters:
action
- the actiondata
- the resource- Returns:
- result
-