Mantid
Loading...
Searching...
No Matches
SetValueWhenProperty.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2021 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#pragma once
8
9#include "MantidKernel/DllConfig.h"
11#include <functional>
12#include <string>
13
14namespace Mantid {
15namespace Kernel {
16
17// Forward declarations
18class IPropertyManager;
19class Property;
20
21class MANTID_KERNEL_DLL SetValueWhenProperty : public IPropertySettings {
22public:
26 SetValueWhenProperty(const std::string &watchedPropName,
27 const std::function<std::string(std::string, std::string)> &changeCriterion)
28 : IPropertySettings(), m_watchedPropName{watchedPropName}, m_changeCriterion{changeCriterion} {}
29
31 bool isConditionChanged(const IPropertyManager *algo, const std::string &changedPropName) const override;
32
35 bool applyChanges(const Mantid::Kernel::IPropertyManager *algo, const std::string &currentPropName) override;
36
38 std::vector<std::string> dependsOn(const std::string &thisProp) const override;
39
41 IPropertySettings *clone() const override;
42
43private:
45 std::string m_watchedPropName;
46
50 std::function<std::string(std::string, std::string)> m_changeCriterion;
51};
52
53} // namespace Kernel
54} // namespace Mantid
Interface to PropertyManager.
Interface for modifiers to Property's that specify if they should be enabled or visible in a GUI.
std::function< std::string(std::string, std::string)> m_changeCriterion
Callback to check and actually apply any required changes: this function returns a new string value f...
SetValueWhenProperty(const std::string &watchedPropName, const std::function< std::string(std::string, std::string)> &changeCriterion)
Constructs an SetValueWhenProperty object which checks the watched property with name given and uses ...
std::string m_watchedPropName
Name of the watched property, which is the property that the current property's value depends on.
Helper class which provides the Collimation Length for SANS instruments.