[90579] | 1 | /* $Id: UIExecutionQueue.h 103982 2024-03-21 11:43:53Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBox Qt GUI - UIExecutionQueue class declaration.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2021-2023 Oracle and/or its affiliates.
|
---|
[90579] | 8 | *
|
---|
[96407] | 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
|
---|
[90579] | 26 | */
|
---|
| 27 |
|
---|
| 28 | #ifndef FEQT_INCLUDED_SRC_objects_UIExecutionQueue_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_objects_UIExecutionQueue_h
|
---|
[90585] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[90579] | 33 |
|
---|
| 34 | /* Qt includes: */
|
---|
| 35 | #include <QObject>
|
---|
| 36 | #include <QQueue>
|
---|
| 37 |
|
---|
[103982] | 38 | /* GUI includes: */
|
---|
| 39 | #include "UILibraryDefs.h"
|
---|
| 40 |
|
---|
[90579] | 41 | /** QObject subclass providing GUI with
|
---|
| 42 | * interface for an execution step. */
|
---|
| 43 | class UIExecutionStep : public QObject
|
---|
| 44 | {
|
---|
| 45 | Q_OBJECT;
|
---|
| 46 |
|
---|
| 47 | signals:
|
---|
| 48 |
|
---|
| 49 | /** Notifies about step finished. */
|
---|
| 50 | void sigStepFinished();
|
---|
| 51 |
|
---|
| 52 | public:
|
---|
| 53 |
|
---|
| 54 | /** Constructs execution step. */
|
---|
| 55 | UIExecutionStep();
|
---|
| 56 |
|
---|
| 57 | /** Executes the step. */
|
---|
| 58 | virtual void exec() = 0;
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | /** QObject subclass providing GUI with
|
---|
| 62 | * an object to process queue of execution steps. */
|
---|
| 63 | class UIExecutionQueue : public QObject
|
---|
| 64 | {
|
---|
| 65 | Q_OBJECT;
|
---|
| 66 |
|
---|
| 67 | signals:
|
---|
| 68 |
|
---|
| 69 | /** Starts the queue. */
|
---|
| 70 | void sigStartQueue();
|
---|
| 71 |
|
---|
| 72 | /** Notifies about queue finished. */
|
---|
| 73 | void sigQueueFinished();
|
---|
| 74 |
|
---|
| 75 | public:
|
---|
| 76 |
|
---|
| 77 | /** Constructs execution queue passing @a pParent to the base-class. */
|
---|
| 78 | UIExecutionQueue(QObject *pParent = 0);
|
---|
| 79 | /** Destructs execution queue. */
|
---|
[103982] | 80 | virtual ~UIExecutionQueue() RT_OVERRIDE RT_FINAL;
|
---|
[90579] | 81 |
|
---|
| 82 | /** Enqueues pStep into queue. */
|
---|
| 83 | void enqueue(UIExecutionStep *pStep);
|
---|
| 84 |
|
---|
| 85 | /** Starts the queue. */
|
---|
| 86 | void start() { emit sigStartQueue(); }
|
---|
| 87 |
|
---|
| 88 | private slots:
|
---|
| 89 |
|
---|
| 90 | /** Starts subsequent step. */
|
---|
| 91 | void sltStartsSubsequentStep();
|
---|
| 92 |
|
---|
| 93 | private:
|
---|
| 94 |
|
---|
| 95 | /** Holds the execution step queue. */
|
---|
| 96 | QQueue<UIExecutionStep*> m_queue;
|
---|
| 97 | /** Holds current step being executed. */
|
---|
| 98 | UIExecutionStep *m_pExecutedStep;
|
---|
| 99 | };
|
---|
| 100 |
|
---|
| 101 | #endif /* !FEQT_INCLUDED_SRC_objects_UIExecutionQueue_h */
|
---|