Mantid
Loading...
Searching...
No Matches
AlgorithmObserver.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
14#include "MantidAPI/DllConfig.h"
15#include <Poco/NObserver.h>
16
17namespace Mantid {
18namespace API {
23class MANTID_API_DLL AlgorithmObserver {
24public:
28
29 // must delete copy operations - Poco::NObserver contains std::atomic which is not copyable
32
33 void observeAll(const IAlgorithm_const_sptr &alg);
35 void observeStarting();
36 void observeStart(const IAlgorithm_const_sptr &alg);
37 void observeFinish(const IAlgorithm_const_sptr &alg);
38 void observeError(const IAlgorithm_const_sptr &alg);
39
40 void stopObserving(const IAlgorithm_const_sptr &alg);
42 void stopObservingManager();
43
44 virtual void progressHandle(const IAlgorithm *alg, double p, const std::string &msg, const double estimatedTime,
45 const int progressPrecision);
47 virtual void startHandle(const IAlgorithm *alg);
48 virtual void finishHandle(const IAlgorithm *alg);
49 virtual void errorHandle(const IAlgorithm *alg, const std::string &what);
50
51private:
52 void _progressHandle(const Poco::AutoPtr<Algorithm::ProgressNotification> &pNf);
55
56 void _startHandle(const Poco::AutoPtr<Algorithm::StartedNotification> &pNf);
59
60 void _finishHandle(const Poco::AutoPtr<Algorithm::FinishedNotification> &pNf);
63
64 void _errorHandle(const Poco::AutoPtr<Algorithm::ErrorNotification> &pNf);
67
68 void _startingHandle(const Poco::AutoPtr<AlgorithmStartingNotification> &pNf);
71};
72
73} // namespace API
74} // namespace Mantid
void stopObserving(AlgorithmObserver &self, const boost::python::object &alg)
void observeProgress(AlgorithmObserver &self, const boost::python::object &alg)
void observeFinish(AlgorithmObserver &self, const boost::python::object &alg)
void observeError(AlgorithmObserver &self, const boost::python::object &alg)
Observes Algorithm notifications: start,progress,finish,error.
virtual void startingHandle(IAlgorithm_sptr alg)
Poco::NObserver< AlgorithmObserver, AlgorithmStartingNotification > m_startingObserver
Poco::NObserver for API::AlgorithmStartingNotification.
virtual ~AlgorithmObserver()
Virtual destructor.
virtual void finishHandle(const IAlgorithm *alg)
AlgorithmObserver(const AlgorithmObserver &)=delete
Poco::NObserver< AlgorithmObserver, Algorithm::ProgressNotification > m_progressObserver
Poco::NObserver for Algorithm::ProgressNotification.
AlgorithmObserver & operator=(const AlgorithmObserver &)=delete
virtual void errorHandle(const IAlgorithm *alg, const std::string &what)
virtual void startHandle(const IAlgorithm *alg)
Poco::NObserver< AlgorithmObserver, Algorithm::StartedNotification > m_startObserver
Poco::NObserver for Algorithm::StartedNotification.
virtual void progressHandle(const IAlgorithm *alg, double p, const std::string &msg, const double estimatedTime, const int progressPrecision)
Poco::NObserver< AlgorithmObserver, Algorithm::ErrorNotification > m_errorObserver
Poco::NObserver for Algorithm::ErrorNotification.
Poco::NObserver< AlgorithmObserver, Algorithm::FinishedNotification > m_finishObserver
Poco::NObserver for Algorithm::FinishedNotification.
IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:45
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< const IAlgorithm > IAlgorithm_const_sptr
shared pointer to Mantid::API::IAlgorithm (const version)
Helper class which provides the Collimation Length for SANS instruments.