1 | /* $Id: UIExecutionQueue.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIExecutionQueue class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_objects_UIExecutionQueue_h
|
---|
29 | #define FEQT_INCLUDED_SRC_objects_UIExecutionQueue_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QObject>
|
---|
36 | #include <QQueue>
|
---|
37 |
|
---|
38 | /** QObject subclass providing GUI with
|
---|
39 | * interface for an execution step. */
|
---|
40 | class UIExecutionStep : public QObject
|
---|
41 | {
|
---|
42 | Q_OBJECT;
|
---|
43 |
|
---|
44 | signals:
|
---|
45 |
|
---|
46 | /** Notifies about step finished. */
|
---|
47 | void sigStepFinished();
|
---|
48 |
|
---|
49 | public:
|
---|
50 |
|
---|
51 | /** Constructs execution step. */
|
---|
52 | UIExecutionStep();
|
---|
53 |
|
---|
54 | /** Executes the step. */
|
---|
55 | virtual void exec() = 0;
|
---|
56 | };
|
---|
57 |
|
---|
58 | /** QObject subclass providing GUI with
|
---|
59 | * an object to process queue of execution steps. */
|
---|
60 | class UIExecutionQueue : public QObject
|
---|
61 | {
|
---|
62 | Q_OBJECT;
|
---|
63 |
|
---|
64 | signals:
|
---|
65 |
|
---|
66 | /** Starts the queue. */
|
---|
67 | void sigStartQueue();
|
---|
68 |
|
---|
69 | /** Notifies about queue finished. */
|
---|
70 | void sigQueueFinished();
|
---|
71 |
|
---|
72 | public:
|
---|
73 |
|
---|
74 | /** Constructs execution queue passing @a pParent to the base-class. */
|
---|
75 | UIExecutionQueue(QObject *pParent = 0);
|
---|
76 | /** Destructs execution queue. */
|
---|
77 | virtual ~UIExecutionQueue() /* override final */;
|
---|
78 |
|
---|
79 | /** Enqueues pStep into queue. */
|
---|
80 | void enqueue(UIExecutionStep *pStep);
|
---|
81 |
|
---|
82 | /** Starts the queue. */
|
---|
83 | void start() { emit sigStartQueue(); }
|
---|
84 |
|
---|
85 | private slots:
|
---|
86 |
|
---|
87 | /** Starts subsequent step. */
|
---|
88 | void sltStartsSubsequentStep();
|
---|
89 |
|
---|
90 | private:
|
---|
91 |
|
---|
92 | /** Holds the execution step queue. */
|
---|
93 | QQueue<UIExecutionStep*> m_queue;
|
---|
94 | /** Holds current step being executed. */
|
---|
95 | UIExecutionStep *m_pExecutedStep;
|
---|
96 | };
|
---|
97 |
|
---|
98 | #endif /* !FEQT_INCLUDED_SRC_objects_UIExecutionQueue_h */
|
---|