Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::Kernel::SetValueWhenProperty Class Reference

#include <SetValueWhenProperty.h>

Inheritance diagram for Mantid::Kernel::SetValueWhenProperty:
Mantid::Kernel::IPropertySettings

Public Member Functions

bool applyChanges (const Mantid::Kernel::IPropertyManager *algo, const std::string &currentPropName) override
 If a new value should be set, the change is applied here.
 
IPropertySettingsclone () const override
 Make a copy of the present type of IPropertySettings.
 
std::vector< std::string > dependsOn (const std::string &thisProp) const override
 Other properties that this property depends on.
 
bool isConditionChanged (const IPropertyManager *algo, const std::string &changedPropName) const override
 Return true when the property changed is the property that the current property's value depends on.
 
 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 the given function to check if changes should be applied.
 
- Public Member Functions inherited from Mantid::Kernel::IPropertySettings
 IPropertySettings ()=default
 Constructor.
 
virtual bool isEnabled (const IPropertyManager *algo) const
 Is the property to be shown as "enabled" in the GUI.
 
virtual bool isVisible (const IPropertyManager *algo) const
 Is the property to be shown in the GUI? Default true.
 
virtual ~IPropertySettings ()=default
 Destructor.
 

Private Attributes

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 for the current property, which in some cases might be the same as the current value.
 
std::string m_watchedPropName
 Name of the watched property, which is the property that the current property's value depends on.
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::Kernel::IPropertySettings
 IPropertySettings (const IPropertySettings &)=default
 

Detailed Description

Definition at line 21 of file SetValueWhenProperty.h.

Constructor & Destructor Documentation

◆ SetValueWhenProperty()

Mantid::Kernel::SetValueWhenProperty::SetValueWhenProperty ( const std::string &  watchedPropName,
const std::function< std::string(std::string, std::string)> &  changeCriterion 
)
inline

Constructs an SetValueWhenProperty object which checks the watched property with name given and uses the given function to check if changes should be applied.

Definition at line 26 of file SetValueWhenProperty.h.

Member Function Documentation

◆ applyChanges()

bool Mantid::Kernel::SetValueWhenProperty::applyChanges ( const Mantid::Kernel::IPropertyManager algo,
const std::string &  currentPropName 
)
overridevirtual

If a new value should be set, the change is applied here.

Return true if the current property was actually changed.

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 41 of file SetValueWhenProperty.cpp.

References Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Kernel::IPropertyManager::getPointerToProperty(), m_changeCriterion, m_watchedPropName, Mantid::Kernel::Property::value(), and Mantid::Kernel::Logger::warning().

◆ clone()

IPropertySettings * Mantid::Kernel::SetValueWhenProperty::clone ( ) const
overridevirtual

Make a copy of the present type of IPropertySettings.

Implements Mantid::Kernel::IPropertySettings.

Definition at line 76 of file SetValueWhenProperty.cpp.

◆ dependsOn()

std::vector< std::string > Mantid::Kernel::SetValueWhenProperty::dependsOn ( const std::string &  thisProp) const
overridevirtual

Other properties that this property depends on.

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 70 of file SetValueWhenProperty.cpp.

References m_watchedPropName.

◆ isConditionChanged()

bool Mantid::Kernel::SetValueWhenProperty::isConditionChanged ( const IPropertyManager algo,
const std::string &  changedPropName 
) const
overridevirtual

Return true when the property changed is the property that the current property's value depends on.

Return true if the changedPropName matches the watchedPropName.

Parameters
algo:: Pointer to the algorithm containing the property
changedPropName:: Name of the property that has just been changed
Returns
:: True if the Property we are watching is the property that just changed, otherwise False

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 36 of file SetValueWhenProperty.cpp.

References Mantid::Kernel::IPropertyManager::getPointerToProperty(), m_watchedPropName, and Mantid::Kernel::Property::name().

Member Data Documentation

◆ m_changeCriterion

std::function<std::string(std::string, std::string)> Mantid::Kernel::SetValueWhenProperty::m_changeCriterion
private

Callback to check and actually apply any required changes: this function returns a new string value for the current property, which in some cases might be the same as the current value.

Definition at line 50 of file SetValueWhenProperty.h.

Referenced by applyChanges().

◆ m_watchedPropName

std::string Mantid::Kernel::SetValueWhenProperty::m_watchedPropName
private

Name of the watched property, which is the property that the current property's value depends on.

Definition at line 45 of file SetValueWhenProperty.h.

Referenced by applyChanges(), dependsOn(), and isConditionChanged().


The documentation for this class was generated from the following files: