Mantid
Loading...
Searching...
No Matches
Framework
PythonInterface
mantid
kernel
src
Exports
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 +
7
#include "
MantidKernel/ConfigPropertyObserver.h
"
8
#include "
MantidPythonInterface/core/CallMethod.h
"
9
#include "
MantidPythonInterface/core/GlobalInterpreterLock.h
"
10
#include <boost/python/class.hpp>
11
#include <boost/python/def.hpp>
12
#include <boost/python/pure_virtual.hpp>
13
14
using namespace
boost::python
;
15
using
Mantid::Kernel::ConfigPropertyObserver
;
16
using
Mantid::PythonInterface::callMethod
;
17
18
class
ConfigPropertyObserverWrapper
:
public
ConfigPropertyObserver
{
19
public
:
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
27
private
:
28
PyObject *
m_self
;
29
};
30
31
namespace
boost::python
{
32
template
<>
struct
has_back_reference<
ConfigPropertyObserverWrapper
> : mpl::true_ {};
33
}
// namespace boost::python
34
35
void
export_ConfigPropertyObserver
() {
36
class_<ConfigPropertyObserverWrapper, boost::noncopyable>(
"ConfigPropertyObserver"
, init<std::string>())
37
.def(init<std::string>())
38
.def(
"onPropertyValueChanged"
, pure_virtual(&
ConfigPropertyObserverWrapper::onPropertyValueChanged
));
39
}
CallMethod.h
ConfigPropertyObserver.h
GlobalInterpreterLock.h
export_ConfigPropertyObserver
void export_ConfigPropertyObserver()
Definition
ConfigPropertyObserver.cpp:35
ConfigPropertyObserverWrapper
Definition
ConfigPropertyObserver.cpp:18
ConfigPropertyObserverWrapper::onPropertyValueChanged
void onPropertyValueChanged(const std::string &newValue, const std::string &prevValue) override
Definition
ConfigPropertyObserver.cpp:23
ConfigPropertyObserverWrapper::m_self
PyObject * m_self
Definition
ConfigPropertyObserver.cpp:28
ConfigPropertyObserverWrapper::ConfigPropertyObserverWrapper
ConfigPropertyObserverWrapper(PyObject *self, const std::string &propertyName)
Definition
ConfigPropertyObserver.cpp:20
Mantid::Kernel::ConfigPropertyObserver
The ConfigObserver is used to observe changes to the value of a single configuration property based o...
Definition
ConfigPropertyObserver.h:17
Mantid::PythonInterface::callMethod
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
boost::python
Definition
NDArray.h:50
Generated by
1.9.8