2021-08-30 22:17:59 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
2022-09-08 19:54:37 +01:00
|
|
|
#include "TaskGroup.hpp"
|
2021-08-30 22:17:59 +01:00
|
|
|
#include "src/TargetController/TargetControllerConsole.hpp"
|
|
|
|
|
|
|
|
|
|
namespace Bloom
|
|
|
|
|
{
|
|
|
|
|
enum class InsightWorkerTaskState: std::uint8_t
|
|
|
|
|
{
|
|
|
|
|
CREATED,
|
|
|
|
|
STARTED,
|
|
|
|
|
FAILED,
|
|
|
|
|
COMPLETED,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class InsightWorkerTask: public QObject
|
|
|
|
|
{
|
2021-10-06 21:12:31 +01:00
|
|
|
Q_OBJECT
|
2021-08-30 22:17:59 +01:00
|
|
|
|
|
|
|
|
public:
|
2021-12-25 21:01:58 +00:00
|
|
|
InsightWorkerTaskState state = InsightWorkerTaskState::CREATED;
|
2021-08-30 22:17:59 +01:00
|
|
|
|
2021-09-02 21:19:46 +01:00
|
|
|
InsightWorkerTask(): QObject(nullptr) {};
|
2021-08-30 22:17:59 +01:00
|
|
|
|
2022-09-08 19:54:37 +01:00
|
|
|
virtual TaskGroups getTaskGroups() const {
|
|
|
|
|
return TaskGroups();
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-09 15:57:24 +01:00
|
|
|
void execute(TargetController::TargetControllerConsole& targetControllerConsole);
|
2021-08-30 22:17:59 +01:00
|
|
|
|
|
|
|
|
signals:
|
2022-04-24 15:31:38 +01:00
|
|
|
/**
|
|
|
|
|
* The InsightWorkerTask::started() signal will be emitted once the task has started (InsightWorker::run() is
|
|
|
|
|
* called)
|
|
|
|
|
*/
|
2021-08-30 22:17:59 +01:00
|
|
|
void started();
|
2022-04-24 15:31:38 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The InsightWorkerTask::completed() signal will be emitted once the task has successfully completed.
|
|
|
|
|
*/
|
2021-08-30 22:17:59 +01:00
|
|
|
void completed();
|
2021-10-06 21:12:31 +01:00
|
|
|
|
2022-04-24 15:31:38 +01:00
|
|
|
/**
|
|
|
|
|
* The InsightWorkerTask::failed() signal will be emitted when the task fails (InsightWorkerTask::run() throws
|
|
|
|
|
* an exception).
|
|
|
|
|
*/
|
|
|
|
|
void failed(QString errorMessage);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The InsightWorkerTask::finished() signal will be emitted at the end of the task, regardless to whether it
|
|
|
|
|
* completed successfully or failed.
|
|
|
|
|
*/
|
|
|
|
|
void finished();
|
|
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
protected:
|
2022-04-09 15:57:24 +01:00
|
|
|
virtual void run(TargetController::TargetControllerConsole& targetControllerConsole) = 0;
|
2021-08-30 22:17:59 +01:00
|
|
|
};
|
|
|
|
|
}
|