Mantid
Loading...
Searching...
No Matches
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MantidQt::API::AlgorithmRunner Class Reference

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>

Inheritance diagram for MantidQt::API::AlgorithmRunner:
MockAlgorithmRunner

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::ErrorNotificationm_errorObserver
 
Poco::NObserver< AlgorithmRunner, Mantid::API::Algorithm::FinishedNotificationm_finishedObserver
 
Poco::NObserver< AlgorithmRunner, Mantid::API::Algorithm::ProgressNotificationm_progressObserver
 

Detailed Description

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:

Date
2012-04-23

Definition at line 32 of file AlgorithmRunner.h.

Constructor & Destructor Documentation

◆ AlgorithmRunner()

MantidQt::API::AlgorithmRunner::AlgorithmRunner ( QObject *  parent = nullptr)
explicit

Constructor.

Definition at line 19 of file AlgorithmRunner.cpp.

◆ ~AlgorithmRunner()

MantidQt::API::AlgorithmRunner::~AlgorithmRunner ( )
override

Destructor.

Definition at line 27 of file AlgorithmRunner.cpp.

References m_asyncAlg, m_asyncResult, m_errorObserver, m_finishedObserver, and m_progressObserver.

Member Function Documentation

◆ algorithmComplete

void MantidQt::API::AlgorithmRunner::algorithmComplete ( bool  error)
signal

Signal emitted when the algorithm has completed execution/encountered an error.

Referenced by handleAlgorithmErrorNotification(), and handleAlgorithmFinishedNotification().

◆ algorithmProgress

void MantidQt::API::AlgorithmRunner::algorithmProgress ( double  p,
const std::string &  msg 
)
signal

Signal emitted when the algorithm reports progress.

Referenced by handleAlgorithmProgressNotification().

◆ cancelRunningAlgorithm()

void MantidQt::API::AlgorithmRunner::cancelRunningAlgorithm ( )
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().

◆ getAlgorithm()

Mantid::API::IAlgorithm_sptr MantidQt::API::AlgorithmRunner::getAlgorithm ( ) const
virtual

Get back a pointer to the running algorithm.

Definition at line 83 of file AlgorithmRunner.cpp.

References m_asyncAlg.

◆ handleAlgorithmErrorNotification()

void MantidQt::API::AlgorithmRunner::handleAlgorithmErrorNotification ( const Poco::AutoPtr< Mantid::API::Algorithm::ErrorNotification > &  pNf)
protected

Observer called when the async algorithm has encountered an error.

Emits a signal for the GUI widget

Parameters
pNf:: notification object

Definition at line 115 of file AlgorithmRunner.cpp.

References algorithmComplete(), and UNUSED_ARG.

◆ handleAlgorithmFinishedNotification()

void MantidQt::API::AlgorithmRunner::handleAlgorithmFinishedNotification ( const Poco::AutoPtr< Mantid::API::Algorithm::FinishedNotification > &  pNf)
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.

Parameters
pNf:: finished notification object.

Definition at line 95 of file AlgorithmRunner.cpp.

References algorithmComplete(), and UNUSED_ARG.

◆ handleAlgorithmProgressNotification()

void MantidQt::API::AlgorithmRunner::handleAlgorithmProgressNotification ( const Poco::AutoPtr< Mantid::API::Algorithm::ProgressNotification > &  pNf)
protected

Observer called when the async algorithm has progress to report.

Parameters
pNf:: notification object

Definition at line 105 of file AlgorithmRunner.cpp.

References algorithmProgress().

◆ startAlgorithm()

void MantidQt::API::AlgorithmRunner::startAlgorithm ( Mantid::API::IAlgorithm_sptr  alg)
virtual

Begin asynchronous execution of an algorithm and observe its execution.

Parameters
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().

Member Data Documentation

◆ m_asyncAlg

Mantid::API::IAlgorithm_sptr MantidQt::API::AlgorithmRunner::m_asyncAlg
protected

Reference to the algorithm executing asynchronously.

Definition at line 68 of file AlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), getAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().

◆ m_asyncResult

Poco::ActiveResult<bool>* MantidQt::API::AlgorithmRunner::m_asyncResult
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().

◆ m_errorObserver

Poco::NObserver<AlgorithmRunner, Mantid::API::Algorithm::ErrorNotification> MantidQt::API::AlgorithmRunner::m_errorObserver
protected

Definition at line 61 of file AlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().

◆ m_finishedObserver

Poco::NObserver<AlgorithmRunner, Mantid::API::Algorithm::FinishedNotification> MantidQt::API::AlgorithmRunner::m_finishedObserver
protected

Definition at line 55 of file AlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().

◆ m_progressObserver

Poco::NObserver<AlgorithmRunner, Mantid::API::Algorithm::ProgressNotification> MantidQt::API::AlgorithmRunner::m_progressObserver
protected

Definition at line 58 of file AlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), startAlgorithm(), and ~AlgorithmRunner().


The documentation for this class was generated from the following files: