Mantid
Loading...
Searching...
No Matches
ConfigPropertyObserver.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 ConfigPropertyObserverWrapper(PyObject *self, const std::string &propertyName)
21 : ConfigPropertyObserver(propertyName), m_self(self) {}
22
23 void onPropertyValueChanged(const std::string &newValue, const std::string &prevValue) override {
24 callMethod<void>(m_self, "onPropertyValueChanged", newValue, prevValue);
25 }
26
27private:
28 PyObject *m_self;
29};
30
31namespace boost::python {
32template <> struct has_back_reference<ConfigPropertyObserverWrapper> : mpl::true_ {};
33} // namespace boost::python
34
36 class_<ConfigPropertyObserverWrapper, boost::noncopyable>("ConfigPropertyObserver", init<std::string>())
37 .def(init<std::string>())
38 .def("onPropertyValueChanged", pure_virtual(&ConfigPropertyObserverWrapper::onPropertyValueChanged));
39}
void export_ConfigPropertyObserver()
void onPropertyValueChanged(const std::string &newValue, const std::string &prevValue) override
ConfigPropertyObserverWrapper(PyObject *self, const std::string &propertyName)
The ConfigObserver is used to observe changes to the value of a single configuration property based o...
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