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

The QtAlgorithmRunner is a QObject that encapsulates methods for running an algorithm asynchronously (in the background) and feeds-back to a GUI widget. More...

#include <QtAlgorithmRunner.h>

Inheritance diagram for MantidQt::API::QtAlgorithmRunner:
MockQtAlgorithmRunner

Signals

void algorithmComplete (bool error)
 Signal emitted when the algorithm has completed execution/encountered an error.
 
void algorithmProgress (double p, const std::string &msg)
 Signal emitted when the algorithm reports progress.
 

Public Member Functions

void cancelRunningAlgorithm ()
 If an algorithm is already running, cancel it.
 
virtual Mantid::API::IAlgorithm_sptr getAlgorithm () const
 Get back a pointer to the running algorithm.
 
 QtAlgorithmRunner (QObject *parent=nullptr)
 
virtual void startAlgorithm (Mantid::API::IAlgorithm_sptr alg)
 Begin asynchronous execution of an algorithm and observe its execution.
 
 ~QtAlgorithmRunner () override
 

Protected Member Functions

void handleAlgorithmErrorNotification (const Poco::AutoPtr< Mantid::API::Algorithm::ErrorNotification > &pNf)
 Observer called when the async algorithm has encountered an error.
 
void handleAlgorithmFinishedNotification (const Poco::AutoPtr< Mantid::API::Algorithm::FinishedNotification > &pNf)
 Algorithm notification handlers.
 
void handleAlgorithmProgressNotification (const Poco::AutoPtr< Mantid::API::Algorithm::ProgressNotification > &pNf)
 Observer called when the async algorithm has progress to report.
 

Protected Attributes

Mantid::API::IAlgorithm_sptr m_asyncAlg
 Reference to the algorithm executing asynchronously.
 
Poco::ActiveResult< bool > * m_asyncResult
 For the asynchronous call in dynamic rebinning.
 
Poco::NObserver< QtAlgorithmRunner, Mantid::API::Algorithm::ErrorNotificationm_errorObserver
 
Poco::NObserver< QtAlgorithmRunner, Mantid::API::Algorithm::FinishedNotificationm_finishedObserver
 
Poco::NObserver< QtAlgorithmRunner, Mantid::API::Algorithm::ProgressNotificationm_progressObserver
 

Detailed Description

The QtAlgorithmRunner 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 QtAlgorithmRunner.h.

Constructor & Destructor Documentation

◆ QtAlgorithmRunner()

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

Definition at line 16 of file QtAlgorithmRunner.cpp.

◆ ~QtAlgorithmRunner()

MantidQt::API::QtAlgorithmRunner::~QtAlgorithmRunner ( )
override

Definition at line 21 of file QtAlgorithmRunner.cpp.

References cancelRunningAlgorithm().

Member Function Documentation

◆ algorithmComplete

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

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

Referenced by handleAlgorithmErrorNotification(), and handleAlgorithmFinishedNotification().

◆ algorithmProgress

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

Signal emitted when the algorithm reports progress.

Referenced by handleAlgorithmProgressNotification().

◆ cancelRunningAlgorithm()

void MantidQt::API::QtAlgorithmRunner::cancelRunningAlgorithm ( )

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 28 of file QtAlgorithmRunner.cpp.

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

Referenced by startAlgorithm(), and ~QtAlgorithmRunner().

◆ getAlgorithm()

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

Get back a pointer to the running algorithm.

Definition at line 70 of file QtAlgorithmRunner.cpp.

References m_asyncAlg.

◆ handleAlgorithmErrorNotification()

void MantidQt::API::QtAlgorithmRunner::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 102 of file QtAlgorithmRunner.cpp.

References algorithmComplete(), and UNUSED_ARG.

◆ handleAlgorithmFinishedNotification()

void MantidQt::API::QtAlgorithmRunner::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 82 of file QtAlgorithmRunner.cpp.

References algorithmComplete(), and UNUSED_ARG.

◆ handleAlgorithmProgressNotification()

void MantidQt::API::QtAlgorithmRunner::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 92 of file QtAlgorithmRunner.cpp.

References algorithmProgress().

◆ startAlgorithm()

void MantidQt::API::QtAlgorithmRunner::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 MockQtAlgorithmRunner.

Definition at line 52 of file QtAlgorithmRunner.cpp.

References cancelRunningAlgorithm(), m_asyncAlg, m_asyncResult, m_errorObserver, m_finishedObserver, and m_progressObserver.

Referenced by MantidQt::MantidWidgets::DataSelector::executeLoadAlgorithm().

Member Data Documentation

◆ m_asyncAlg

Mantid::API::IAlgorithm_sptr MantidQt::API::QtAlgorithmRunner::m_asyncAlg
protected

Reference to the algorithm executing asynchronously.

Definition at line 68 of file QtAlgorithmRunner.h.

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

◆ m_asyncResult

Poco::ActiveResult<bool>* MantidQt::API::QtAlgorithmRunner::m_asyncResult
protected

For the asynchronous call in dynamic rebinning.

Holds the result of asyncExecute() algorithm call

Definition at line 65 of file QtAlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), and startAlgorithm().

◆ m_errorObserver

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

Definition at line 61 of file QtAlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), and startAlgorithm().

◆ m_finishedObserver

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

Definition at line 55 of file QtAlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), and startAlgorithm().

◆ m_progressObserver

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

Definition at line 58 of file QtAlgorithmRunner.h.

Referenced by cancelRunningAlgorithm(), and startAlgorithm().


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