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
34 void applyChanges(const Mantid::Kernel::IPropertyManager *algo, Kernel::Property *const pProp) override;
35
37 void modify_allowed_values(Property *const);
38
41 std::string getPropertyValue(const IPropertyManager *algo) const;
43 IPropertySettings *clone() const override;
44
45private:
48 std::string m_watchedPropName;
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.
Base class for properties.
Definition: Property.h:94
std::function< std::string(std::string, std::string)> m_changeCriterion
Function to check if changes should be applied.
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, based on which we may set the value of the current property.
Helper class which provides the Collimation Length for SANS instruments.