Mantid
|
The AlgorithmRunner is a QObject that encapsulates methods for running an algorithm asynchronously (in the background) and feeds-back to a GUI widget. More...
#include <AlgorithmRunner.h>
Signals | |
void | algorithmComplete (bool error) |
Signal emitted when the algorithm has completed execution/encountered an error. More... | |
void | algorithmProgress (double p, const std::string &msg) |
Signal emitted when the algorithm reports progress. More... | |
Public Member Functions | |
AlgorithmRunner (QObject *parent=nullptr) | |
Constructor. More... | |
virtual void | cancelRunningAlgorithm () |
If an algorithm is already running, cancel it. More... | |
virtual Mantid::API::IAlgorithm_sptr | getAlgorithm () const |
Get back a pointer to the running algorithm. More... | |
virtual void | startAlgorithm (Mantid::API::IAlgorithm_sptr alg) |
Begin asynchronous execution of an algorithm and observe its execution. More... | |
~AlgorithmRunner () override | |
Destructor. More... | |
Protected Member Functions | |
void | handleAlgorithmErrorNotification (const Poco::AutoPtr< Mantid::API::Algorithm::ErrorNotification > &pNf) |
Observer called when the async algorithm has encountered an error. More... | |
void | handleAlgorithmFinishedNotification (const Poco::AutoPtr< Mantid::API::Algorithm::FinishedNotification > &pNf) |
Algorithm notification handlers. More... | |
void | handleAlgorithmProgressNotification (const Poco::AutoPtr< Mantid::API::Algorithm::ProgressNotification > &pNf) |
Observer called when the async algorithm has progress to report. More... | |
Protected Attributes | |
Mantid::API::IAlgorithm_sptr | m_asyncAlg |
Reference to the algorithm executing asynchronously. More... | |
Poco::ActiveResult< bool > * | m_asyncResult |
For the asynchronous call in dynamic rebinning. More... | |
Poco::NObserver< AlgorithmRunner, Mantid::API::Algorithm::ErrorNotification > | m_errorObserver |
Poco::NObserver< AlgorithmRunner, Mantid::API::Algorithm::FinishedNotification > | m_finishedObserver |
Poco::NObserver< AlgorithmRunner, Mantid::API::Algorithm::ProgressNotification > | m_progressObserver |
The AlgorithmRunner is a QObject that encapsulates methods for running an algorithm asynchronously (in the background) and feeds-back to a GUI widget.
The QObject keeps track of a running algorithm. Any already-running algorithm is cancelled if it gets started again. Signals are emitted when the algorithm progresses or finishes.
TO USE:
Definition at line 32 of file AlgorithmRunner.h.
|
explicit |
Constructor.
Definition at line 19 of file AlgorithmRunner.cpp.
|
override |
Destructor.
Definition at line 27 of file AlgorithmRunner.cpp.
References m_asyncAlg, m_asyncResult, m_errorObserver, m_finishedObserver, and m_progressObserver.
|
signal |
Signal emitted when the algorithm has completed execution/encountered an error.
Referenced by handleAlgorithmErrorNotification(), and handleAlgorithmFinishedNotification().
|
signal |
Signal emitted when the algorithm reports progress.
Referenced by handleAlgorithmProgressNotification().
|
virtual |
If an algorithm is already running, cancel it.
Does nothing if no algorithm is running. This blocks for up to 1 second to wait for the algorithm to finish cancelling.
Definition at line 41 of file AlgorithmRunner.cpp.
References m_asyncAlg, m_asyncResult, m_errorObserver, m_finishedObserver, and m_progressObserver.
Referenced by startAlgorithm().
|
virtual |
Get back a pointer to the running algorithm.
Definition at line 83 of file AlgorithmRunner.cpp.
References m_asyncAlg.
|
protected |
Observer called when the async algorithm has encountered an error.
Emits a signal for the GUI widget
pNf | :: notification object |
Definition at line 115 of file AlgorithmRunner.cpp.
References algorithmComplete(), and UNUSED_ARG.
|
protected |
Algorithm notification handlers.
Observer called when the asynchronous algorithm has completed.
Emits a signal for the GUI widget
This is called in a separate (non-GUI) thread and so CANNOT directly change the gui.
pNf | :: finished notification object. |
Definition at line 95 of file AlgorithmRunner.cpp.
References algorithmComplete(), and UNUSED_ARG.
|
protected |
Observer called when the async algorithm has progress to report.
pNf | :: notification object |
Definition at line 105 of file AlgorithmRunner.cpp.
References algorithmProgress().
|
virtual |
Begin asynchronous execution of an algorithm and observe its execution.
alg | :: algorithm to execute. All properties should have been set properly. |
Reimplemented in MockAlgorithmRunner.
Definition at line 65 of file AlgorithmRunner.cpp.
References cancelRunningAlgorithm(), m_asyncAlg, m_asyncResult, m_errorObserver, m_finishedObserver, and m_progressObserver.
Referenced by MantidQt::MantidWidgets::DataSelector::autoLoadFile().
|
protected |
Reference to the algorithm executing asynchronously.
Definition at line 68 of file AlgorithmRunner.h.
Referenced by cancelRunningAlgorithm(), getAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().
|
protected |
For the asynchronous call in dynamic rebinning.
Holds the result of asyncExecute() algorithm call
Definition at line 65 of file AlgorithmRunner.h.
Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().
|
protected |
Definition at line 61 of file AlgorithmRunner.h.
Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().
|
protected |
Definition at line 55 of file AlgorithmRunner.h.
Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().
|
protected |
Definition at line 58 of file AlgorithmRunner.h.
Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().