Mantid
Loading...
Searching...
No Matches
AlgorithmObserver.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
9
10#include <boost/python/class.hpp>
11#include <boost/python/register_ptr_to_python.hpp>
12
13using namespace Mantid::API;
14using namespace Mantid::PythonInterface;
15using namespace boost::python;
16
17void observeFinish(AlgorithmObserver &self, const boost::python::object &alg) {
18 const IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg);
19 self.observeFinish(calg);
20}
21
22void observeError(AlgorithmObserver &self, const boost::python::object &alg) {
23 const IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg);
24 self.observeError(calg);
25}
26
27void observeProgress(AlgorithmObserver &self, const boost::python::object &alg) {
28 const IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg);
29 self.observeProgress(calg);
30}
31
32void stopObserving(AlgorithmObserver &self, const boost::python::object &alg) {
33 const IAlgorithm_sptr &calg = boost::python::extract<IAlgorithm_sptr &>(alg);
34 self.stopObserving(calg);
35}
36
38
40
41 register_ptr_to_python<std::shared_ptr<AlgorithmObserver>>();
42
43 class_<AlgorithmObserver, bases<>, std::shared_ptr<AlgorithmObserverAdapter>, boost::noncopyable>(
44 "AlgorithmObserver", "Observes Algorithm notifications: start,progress,finish,error.")
45 .def("observeStarting", &AlgorithmObserver::observeStarting, arg("self"),
46 "Observe the AlgorithmManager for starting algorithms.")
47 .def("observeFinish", &observeFinish, (arg("self"), arg("alg")), "Observe algorithm for its finish notification.")
48 .def("observeError", &observeError, (arg("self"), arg("alg")), "Observe algorithm for its error notification.")
49 .def("observeProgress", &observeProgress, (arg("self"), arg("alg")),
50 "Observe algorithm for its progress notification.")
51 .def("stopObserving", &stopObserving, (arg("self"), arg("alg")), "Remove all observers from the algorithm.");
52}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition: GetPointer.h:17
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 export_algorithm_observer()
void observeError(AlgorithmObserver &self, const boost::python::object &alg)
Observes Algorithm notifications: start,progress,finish,error.
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.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm