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 +
9
10namespace Mantid::Kernel {
14ConfigObserver::ConfigObserver() : m_valueChangeListener(*this, &ConfigObserver::notifyValueChanged) {
15 ConfigService::Instance().addObserver(m_valueChangeListener);
16}
17
27 : m_valueChangeListener(*this, &ConfigObserver::notifyValueChanged) {
28 UNUSED_ARG(other);
29 ConfigService::Instance().addObserver(m_valueChangeListener);
30}
31
43 UNUSED_ARG(other);
44 return *this;
45}
46
47ConfigObserver::~ConfigObserver() noexcept { ConfigService::Instance().removeObserver(m_valueChangeListener); }
48
56void ConfigObserver::notifyValueChanged(const std::string &name, const std::string &newValue,
57 const std::string &oldValue) {
58 onValueChanged(name, newValue, oldValue);
59}
60
67 notifyValueChanged(notification->key(), notification->curValue(), notification->preValue());
68}
69} // namespace Mantid::Kernel
std::string name
Definition Run.cpp:60
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition System.h:48
The ConfigObserver is used to observe changes in the configuration based on notifications sent from t...
ConfigObserver & operator=(const ConfigObserver &other)
Nothing to do but we must overload the = operator to prevent a default copy which would produce incor...
void notifyValueChanged(const std::string &name, const std::string &newValue, const std::string &prevValue)
Called when a config property's value is changed.
virtual void onValueChanged(const std::string &name, const std::string &newValue, const std::string &prevValue)=0
Poco::NObserver< ConfigObserver, Mantid::Kernel::ConfigValChangeNotification > m_valueChangeListener
ConfigObserver()
Begins listening to notifications from the global ConfigService.
const Poco::AutoPtr< Mantid::Kernel::ConfigServiceImpl::ValueChanged > & ConfigValChangeNotification_ptr