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
37void callReleasingGIL(AnalysisDataServiceObserver &self, bool on, ObserverMethod method) {
39 (self.*method)(on);
40}
41} // namespace
42
44 boost::python::class_<AnalysisDataServiceObserver, bases<>, AnalysisDataServiceObserverAdapter, boost::noncopyable>(
45 "AnalysisDataServiceObserver", "Observes AnalysisDataService notifications: all only")
46 .def("observeAll",
47 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeAll),
48 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
49 "Observe AnalysisDataService for any changes")
50 .def("observeAdd",
51 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeAdd),
52 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
53 "Observe AnalysisDataService for a workspace being added")
54 .def("observeReplace",
55 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeReplace),
56 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
57 "Observe AnalysisDataService for a workspace being replaced")
58 .def("observeDelete",
59 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeDelete),
60 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
61 "Observe AnalysisDataService for a workspace being deleted")
62 .def("observeClear",
63 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeClear),
64 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
65 "Observe AnalysisDataService for it being cleared")
66 .def("observeRename",
67 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeRename),
68 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
69 "Observe AnalysisDataService for a workspace being renamed")
70 .def("observeGroup",
71 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeGroup),
72 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
73 "Observe AnalysisDataService for a group being added/made in the ADS")
74 .def("observeUnGroup",
75 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeUnGroup),
76 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
77 "Observe AnalysisDataService for a group being removed from the ADS")
78 .def("observeGroupUpdate",
79 make_function(std::bind(callReleasingGIL, _1, _2, &AnalysisDataServiceObserver::observeGroupUpdate),
80 default_call_policies(), (arg("self"), arg("on")), ObserverMethodSignature()),
81 "Observe AnalysisDataService for a group being updated by being "
82 "added to or removed from");
83}
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.