Mantid
Loading...
Searching...
No Matches
AnalysisDataServiceObserver.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 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 +
11
12#include <boost/mpl/vector.hpp>
13#include <boost/python/bases.hpp>
14#include <boost/python/class.hpp>
15#include <boost/python/make_function.hpp>
16#include <functional>
17
18using namespace std::placeholders;
19using namespace Mantid::API;
20using namespace Mantid::PythonInterface;
21using namespace boost::python;
23using ObserverMethodSignature = boost::mpl::vector<void, AnalysisDataServiceObserver &, bool>;
24
25namespace {
26
37// cppcheck-suppress constParameterCallback
38void callReleasingGIL(AnalysisDataServiceObserver &self, bool on, ObserverMethod method) {
40 (self.*method)(on);
41}
42} // namespace
43
45 boost::python::class_<AnalysisDataServiceObserver, bases<>, AnalysisDataServiceObserverAdapter, boost::noncopyable>(
46 "AnalysisDataServiceObserver", "Observes AnalysisDataService notifications: all only")
47 .def("observeAll",
48 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeAll),
49 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
50 "Observe AnalysisDataService for any changes")
51 .def("observeAdd",
52 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeAdd),
53 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
54 "Observe AnalysisDataService for a workspace being added")
55 .def("observeReplace",
56 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeReplace),
57 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
58 "Observe AnalysisDataService for a workspace being replaced")
59 .def("observeDelete",
60 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeDelete),
61 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
62 "Observe AnalysisDataService for a workspace being deleted")
63 .def("observeClear",
64 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeClear),
65 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
66 "Observe AnalysisDataService for it being cleared")
67 .def("observeRename",
68 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeRename),
69 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
70 "Observe AnalysisDataService for a workspace being renamed")
71 .def("observeGroup",
72 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeGroup),
73 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
74 "Observe AnalysisDataService for a group being added/made in the ADS")
75 .def("observeUnGroup",
76 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeUnGroup),
77 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
78 "Observe AnalysisDataService for a group being removed from the ADS")
79 .def("observeGroupUpdate",
80 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeGroupUpdate),
81 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
82 "Observe AnalysisDataService for a group being updated by being "
83 "added to or removed from");
84}
boost::mpl::vector< void, AnalysisDataServiceObserver &, bool > ObserverMethodSignature
void export_AnalysisDataServiceObserver()
void(AnalysisDataServiceObserver::*)(bool) ObserverMethod
void observeGroup(bool turnOn=true)
Function will add/remove the observer to the ADS for when a group is added/created in the ADS.
void observeReplace(bool turnOn=true)
Function will add/remove the observer to the ADS for when a workspace is replaced.
void observeAll(bool turnOn=true)
Function will turn on/off all observers for the ADS.
void observeRename(bool turnOn=true)
Function will add/remove the observer to the ADS for when a workspace is renamed.
void observeUnGroup(bool turnOn=true)
Function will add/remove the observer to the ADS for when a group is removed/delete from the ADS.
void observeDelete(bool turnOn=true)
Function will add/remove the observer to the ADS for when a workspace is deleted.
void observeClear(bool turnOn=true)
Function will add/remove the observer to the ADS for when the ADS is cleared.
void observeAdd(bool turnOn=true)
Function will add/remove the observer to the ADS for when a workspace is added to it.
void observeGroupUpdate(bool turnOn=true)
Function will add/remove the observer to the ADS for if a workspace is added to a group or removed.
A wrapper class helping to export AnalysisDataServiceObserver to python.
Defines a structure for releasing the Python GIL using the RAII pattern.