Mantid
Loading...
Searching...
No Matches
QtJobRunner.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2022 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7
13
14using namespace MantidQt::API;
15
16namespace MantidQt::API {
17
18QtJobRunner::QtJobRunner(bool const stopOnFailure) : QObject(), m_batchAlgoRunner(this) {
19 qRegisterMetaType<API::IConfiguredAlgorithm_sptr>("MantidQt::API::IConfiguredAlgorithm_sptr");
20 m_batchAlgoRunner.stopOnFailure(stopOnFailure);
22}
23
25
27
28void QtJobRunner::setAlgorithmQueue(std::deque<IConfiguredAlgorithm_sptr> algorithms) {
29 m_batchAlgoRunner.setQueue(std::move(algorithms));
30}
31
33
37
39
41 connect(&m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(onBatchComplete(bool)));
42 connect(&m_batchAlgoRunner, SIGNAL(batchCancelled()), this, SLOT(onBatchCancelled()));
43 connect(&m_batchAlgoRunner, SIGNAL(algorithmStarted(MantidQt::API::IConfiguredAlgorithm_sptr)), this,
45 connect(&m_batchAlgoRunner, SIGNAL(algorithmComplete(MantidQt::API::IConfiguredAlgorithm_sptr)), this,
47 connect(&m_batchAlgoRunner, SIGNAL(algorithmError(MantidQt::API::IConfiguredAlgorithm_sptr, std::string)), this,
49}
50
52
54
58
62
63void QtJobRunner::onAlgorithmError(API::IConfiguredAlgorithm_sptr algorithm, const std::string &message) {
64 m_notifyee->notifyAlgorithmError(algorithm, message);
65}
66
67} // namespace MantidQt::API
double error
void setQueue(std::deque< IConfiguredAlgorithm_sptr > algorithm)
Set the queue of algorithms.
void stopOnFailure(bool stopOnFailure)
Sets if the execuion should be stopped if an error is detected.
void cancelBatch()
Request to cancel processing the batch.
void executeAlgorithmAsync(IConfiguredAlgorithm_sptr algorithm)
Starts a single algorithm and returns immediately.
void executeBatchAsync()
Starts the batch executing and returns immediately.
void clearQueue()
Clears all algorithms from queue.
JobRunnerSubscriber is an interface to a class that subscribes to notifications from an IJobRunner.
Definition IJobRunner.h:24
virtual void notifyBatchComplete(bool error)=0
virtual void notifyAlgorithmComplete(API::IConfiguredAlgorithm_sptr &algorithm)=0
virtual void notifyAlgorithmStarted(API::IConfiguredAlgorithm_sptr &algorithm)=0
virtual void notifyAlgorithmError(API::IConfiguredAlgorithm_sptr &algorithm, std::string const &message)=0
MantidQt::API::BatchAlgorithmRunner m_batchAlgoRunner
Definition QtJobRunner.h:41
void onAlgorithmError(MantidQt::API::IConfiguredAlgorithm_sptr algorithm, const std::string &errorMessage)
void setAlgorithmQueue(std::deque< MantidQt::API::IConfiguredAlgorithm_sptr > algorithms) override
void onBatchComplete(bool error)
QtJobRunner(bool const stopOnFailure=false)
void onAlgorithmStarted(MantidQt::API::IConfiguredAlgorithm_sptr algorithm)
void executeAlgorithm(MantidQt::API::IConfiguredAlgorithm_sptr algorithm) override
void clearAlgorithmQueue() override
JobRunnerSubscriber * m_notifyee
Definition QtJobRunner.h:42
void cancelAlgorithmQueue() override
void subscribe(JobRunnerSubscriber *notifyee) override
void onAlgorithmComplete(MantidQt::API::IConfiguredAlgorithm_sptr algorithm)
void executeAlgorithmQueue() override
std::shared_ptr< IConfiguredAlgorithm > IConfiguredAlgorithm_sptr