Mantid
Loading...
Searching...
No Matches
Framework
PythonInterface
mantid
kernel
src
Exports
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 +
7
#include "
MantidKernel/ConfigObserver.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::ConfigObserver
;
16
using
Mantid::PythonInterface::callMethod
;
17
18
class
ConfigObserverWrapper
:
public
ConfigObserver
{
19
public
:
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
27
private
:
28
PyObject *
m_self
;
29
};
30
31
namespace
boost::python
{
32
template
<>
struct
has_back_reference<
ConfigObserverWrapper
> : mpl::true_ {};
33
}
// namespace boost::python
34
35
void
export_ConfigObserver
() {
36
class_<ConfigObserverWrapper, boost::noncopyable>(
"ConfigObserver"
)
37
.def(
"onValueChanged"
, pure_virtual(&
ConfigObserverWrapper::onValueChanged
));
38
}
name
std::string name
Definition
Run.cpp:60
CallMethod.h
ConfigObserver.h
GlobalInterpreterLock.h
export_ConfigObserver
void export_ConfigObserver()
Definition
ConfigObserver.cpp:35
ConfigObserverWrapper
Definition
ConfigObserver.cpp:18
ConfigObserverWrapper::m_self
PyObject * m_self
Definition
ConfigObserver.cpp:28
ConfigObserverWrapper::ConfigObserverWrapper
ConfigObserverWrapper(PyObject *self)
Definition
ConfigObserver.cpp:20
ConfigObserverWrapper::onValueChanged
void onValueChanged(const std::string &name, const std::string &newValue, const std::string &prevValue) override
Definition
ConfigObserver.cpp:23
Mantid::Kernel::ConfigObserver
The ConfigObserver is used to observe changes in the configuration based on notifications sent from t...
Definition
ConfigObserver.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