Mantid
Loading...
Searching...
No Matches
AlgorithmProgressModel.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 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 +
10
12
14 : AlgorithmObserver(), m_dialogPresenter{nullptr}, m_mainWindowPresenter{presenter} {
15
16 // Start capturing the triggers from ALL algorithms starting
17 // this allows us to attach an observer to the algorithm to track the
18 // start, progress, finish and errors.
20}
21
23
25 this->m_dialogPresenter = presenter;
26}
27
32 observeStart(alg);
33 observeProgress(alg);
34 observeFinish(alg);
35 observeError(alg);
36}
43
45 m_dialogPresenter->algorithmStarted(alg->getAlgorithmID());
46 }
47}
48
56 const std::string &message, const double estimatedTime,
57 const int progressPrecision) {
58 m_mainWindowPresenter->updateProgressBar(alg->getAlgorithmID(), progress, message, estimatedTime, progressPrecision);
60 m_dialogPresenter->updateProgressBar(alg->getAlgorithmID(), progress, message, estimatedTime, progressPrecision);
61 }
62}
72void AlgorithmProgressModel::errorHandle(const Mantid::API::IAlgorithm *alg, const std::string &what) {
73 UNUSED_ARG(what);
74 this->removeFrom(alg);
75}
76
80 this->stopObserving(alg);
83 m_dialogPresenter->algorithmEnded(alg->getAlgorithmID());
84 }
85}
86} // namespace MantidQt::MantidWidgets
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
void setDialog(AlgorithmProgressDialogPresenter *)
void startingHandle(Mantid::API::IAlgorithm_sptr alg) override
Observes ALL starting algorithms.
QPointer< AlgorithmProgressDialogPresenter > m_dialogPresenter
void progressHandle(const Mantid::API::IAlgorithm *alg, double progress, const std::string &message, const double estimatedTime, const int progressPrecision) override
Triggered when the algorithm reports progress.
void removeFrom(const Mantid::API::IAlgorithm *alg)
Removes itself as an observer from the algorithm.
AlgorithmProgressModel(AlgorithmProgressPresenter *presenter)
void finishHandle(const Mantid::API::IAlgorithm *alg) override
Triggered when the algorithm is finished.
void startHandle(const Mantid::API::IAlgorithm *alg) override
Triggered when the algorithm is executed.
void errorHandle(const Mantid::API::IAlgorithm *alg, const std::string &what) override
Triggered when the algorithm encounters an error.
void updateProgressBar(Mantid::API::AlgorithmID, double, const std::string &, const double estimatedTime, const int progressPrecision)
Signals to the presenters that there has been progress in one of the algorithms.
void algorithmStarted(Mantid::API::AlgorithmID)
Signals to the presenters that an algorithm has started.
void algorithmEnded(Mantid::API::AlgorithmID)
Signals to the presenters that an algorithm has ended.
Observes Algorithm notifications: start,progress,finish,error.
void observeStart(const IAlgorithm_const_sptr &alg)
Connect to algorithm alg and observe its start notification.
void observeFinish(const IAlgorithm_const_sptr &alg)
Connect to algorithm alg and observe its finish notification.
void observeStarting()
Connect to AlgorithmManager and observe its starting notifications.
void observeProgress(const IAlgorithm_const_sptr &alg)
Connect to algorithm alg and observe its progress notification.
void stopObserving(const IAlgorithm_const_sptr &alg)
Disconnect from algorithm alg.
void observeError(const IAlgorithm_const_sptr &alg)
Connect to algorithm alg and observe its error notification.
void stopObservingManager()
Disconnect from the algorithm manager.
IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:45
virtual AlgorithmID getAlgorithmID() const =0
Algorithm ID.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm