Mantid
Loading...
Searching...
No Matches
ConfigObserver.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 +
10#include <boost/python/class.hpp>
11#include <boost/python/def.hpp>
12#include <boost/python/pure_virtual.hpp>
13
14using namespace boost::python;
17
19public:
20 explicit ConfigObserverWrapper(PyObject *self) : m_self(self) {}
21 using ConfigObserver::notifyValueChanged;
22
23 void onValueChanged(const std::string &name, const std::string &newValue, const std::string &prevValue) override {
24 callMethod<void>(m_self, "onValueChanged", name, newValue, prevValue);
25 }
26
27private:
28 PyObject *m_self;
29};
30
31namespace boost::python {
32template <> struct has_back_reference<ConfigObserverWrapper> : mpl::true_ {};
33} // namespace boost::python
34
36 class_<ConfigObserverWrapper, boost::noncopyable>("ConfigObserver")
37 .def("onValueChanged", pure_virtual(&ConfigObserverWrapper::onValueChanged));
38}
void export_ConfigObserver()
ConfigObserverWrapper(PyObject *self)
void onValueChanged(const std::string &name, const std::string &newValue, const std::string &prevValue) override
The ConfigObserver is used to observe changes in the configuration based on notifications sent from t...
ReturnType callMethod(PyObject *obj, const char *methodName, const Args &...args)
Wrapper around boost::python::call_method to acquire GIL for duration of call.
Definition: CallMethod.h:87