java.lang.Object
io.qt.core.QScope
- All Implemented Interfaces:
AutoCloseable
QScope is an object life-time manager to be used in a try-with-resource block.
All object created with this scope are cleaned up (disposed) at the end of the scope.
Example:
try(QScope scope = new QScope()){
QDialog dialog = scope.create(QDialog::new);
dialog.exec();
}
// dialog is disposed
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Factory for argument-less constructorsstatic interface
Factory for one argument taking constructorsstatic interface
Factory for two arguments taking constructorsstatic interface
QScope.Factory3<A,
B, C, R> Factory for 3 arguments taking constructorsstatic interface
Factory for 4 arguments taking constructorsstatic interface
Factory for 5 arguments taking constructorsstatic interface
Factory for 6 arguments taking constructorsstatic interface
Factory for 7 arguments taking constructorsstatic interface
Factory for 8 arguments taking constructorsstatic interface
Factory for 9 arguments taking constructors -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionLet given action be performed at the end of the scope.<T> T
The given object is managed by the scope, i.e.<T extends QtObjectInterface>
Tcapture
(T object) The given object is managed by the scope, i.e.boolean
Forces the object's cleanup.void
close()
Performs a cleanup on all<O extends QtObjectInterface>
Ocreate
(QScope.Factory<O> factory) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A>
Ocreate
(QScope.Factory1<A, O> factory, A arg0) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B>
Ocreate
(QScope.Factory2<A, B, O> factory, A arg0, B arg1) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C>
Ocreate
(QScope.Factory3<A, B, C, O> factory, A arg0, B arg1, C arg2) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C, D>
Ocreate
(QScope.Factory4<A, B, C, D, O> factory, A arg0, B arg1, C arg2, D arg3) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C, D, E>
Ocreate
(QScope.Factory5<A, B, C, D, E, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C, D, E, F>
Ocreate
(QScope.Factory6<A, B, C, D, E, F, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C, D, E, F, G>
Ocreate
(QScope.Factory7<A, B, C, D, E, F, G, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C, D, E, F, G, H>
Ocreate
(QScope.Factory8<A, B, C, D, E, F, G, H, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7) Creates a new object being managed by this scope.<O extends QtObjectInterface,
A, B, C, D, E, F, G, H, I>
Ocreate
(QScope.Factory9<A, B, C, D, E, F, G, H, I, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8) Creates a new object being managed by this scope.<O> O
create
(Consumer<O> cleanup, QScope.Factory<O> factory) Creates a new object being managed by this scope with cleanup function.<O,
A> O create
(Consumer<O> cleanup, QScope.Factory1<A, O> factory, A arg0) Creates a new object being managed by this scope with cleanup function.<O,
A, B> O create
(Consumer<O> cleanup, QScope.Factory2<A, B, O> factory, A arg0, B arg1) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C>
Ocreate
(Consumer<O> cleanup, QScope.Factory3<A, B, C, O> factory, A arg0, B arg1, C arg2) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C, D>
Ocreate
(Consumer<O> cleanup, QScope.Factory4<A, B, C, D, O> factory, A arg0, B arg1, C arg2, D arg3) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C, D, E>
Ocreate
(Consumer<O> cleanup, QScope.Factory5<A, B, C, D, E, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C, D, E, F>
Ocreate
(Consumer<O> cleanup, QScope.Factory6<A, B, C, D, E, F, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C, D, E, F, G>
Ocreate
(Consumer<O> cleanup, QScope.Factory7<A, B, C, D, E, F, G, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C, D, E, F, G, H>
Ocreate
(Consumer<O> cleanup, QScope.Factory8<A, B, C, D, E, F, G, H, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7) Creates a new object being managed by this scope with cleanup function.<O,
A, B, C, D, E, F, G, H, I>
Ocreate
(Consumer<O> cleanup, QScope.Factory9<A, B, C, D, E, F, G, H, I, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8) Creates a new object being managed by this scope with cleanup function.boolean
Removes the given object from this scope.
-
Constructor Details
-
QScope
public QScope()Default constructor
-
-
Method Details
-
close
Performs a cleanup on all- Specified by:
close
in interfaceAutoCloseable
-
release
Removes the given object from this scope.- Parameters:
object
-- Returns:
- success
-
cleanup
Forces the object's cleanup.- Parameters:
object
-- Returns:
- success
-
capture
Let given action be performed at the end of the scope.- Parameters:
action
-
-
capture
The given object is managed by the scope, i.e. disposed at its closing.- Parameters:
object
-- Returns:
- object
-
capture
The given object is managed by the scope, i.e. cleaned up at its closing.- Parameters:
cleanup
-object
-- Returns:
- object
-
create
Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C> (QScope.Factory3<A, B, C, O> factory, A arg0, B arg1, C arg2) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C, D> (QScope.Factory4<A, B, C, D, O> factory, A arg0, B arg1, C arg2, D arg3) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C, D, E> (QScope.Factory5<A, B, C, D, E, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C, D, E, F> (QScope.Factory6<A, B, C, D, E, F, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C, D, E, F, G> (QScope.Factory7<A, B, C, D, E, F, G, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C, D, E, F, G, H> (QScope.Factory8<A, B, C, D, E, F, G, H, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
public <O extends QtObjectInterface,A, O createB, C, D, E, F, G, H, I> (QScope.Factory9<A, B, C, D, E, F, G, H, I, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8) Creates a new object being managed by this scope.- Parameters:
factory
- constructor- Returns:
- new scoped object
-
create
Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C> (Consumer<O> cleanup, QScope.Factory3<A, B, C, O> factory, A arg0, B arg1, C arg2) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C, D> (Consumer<O> cleanup, QScope.Factory4<A, B, C, D, O> factory, A arg0, B arg1, C arg2, D arg3) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C, D, E> (Consumer<O> cleanup, QScope.Factory5<A, B, C, D, E, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C, D, E, F> (Consumer<O> cleanup, QScope.Factory6<A, B, C, D, E, F, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C, D, E, F, G> (Consumer<O> cleanup, QScope.Factory7<A, B, C, D, E, F, G, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C, D, E, F, G, H> (Consumer<O> cleanup, QScope.Factory8<A, B, C, D, E, F, G, H, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-
create
public <O,A, O createB, C, D, E, F, G, H, I> (Consumer<O> cleanup, QScope.Factory9<A, B, C, D, E, F, G, H, I, O> factory, A arg0, B arg1, C arg2, D arg3, E arg4, F arg5, G arg6, H arg7, I arg8) Creates a new object being managed by this scope with cleanup function.- Parameters:
cleanup
- the destroyer functionfactory
- constructor- Returns:
- new scoped object
-