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

#include <SetDefaultWhenProperty.h>

Inheritance diagram for Mantid::Kernel::SetDefaultWhenProperty:
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 change criterion should be tested.
 
 SetDefaultWhenProperty (const std::string &watchedPropName, const std::function< bool(const Mantid::Kernel::IPropertyManager *, Property *, Property *)> &changeCriterion)
 Constructs an SetDefaultWhenProperty instance which sets the dynamic-default value of a property when the changeCriterion function is satisfied.
 
- 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< bool(const Mantid::Kernel::IPropertyManager *, Property *, Property *)> m_changeCriterion
 Criterion to determine if a new dynamic-default value should be set: in which case this function should modify the current property's value and return True, otherwise it should return False.
 
std::string m_watchedPropName
 Name of the watched property.
 

Additional Inherited Members

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

Detailed Description

Definition at line 21 of file SetDefaultWhenProperty.h.

Constructor & Destructor Documentation

◆ SetDefaultWhenProperty()

Mantid::Kernel::SetDefaultWhenProperty::SetDefaultWhenProperty ( const std::string &  watchedPropName,
const std::function< bool(const Mantid::Kernel::IPropertyManager *, Property *, Property *)> &  changeCriterion 
)
inline

Constructs an SetDefaultWhenProperty instance which sets the dynamic-default value of a property when the changeCriterion function is satisfied.

Definition at line 25 of file SetDefaultWhenProperty.h.

Member Function Documentation

◆ applyChanges()

bool Mantid::Kernel::SetDefaultWhenProperty::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 current property was changed.

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 42 of file SetDefaultWhenProperty.cpp.

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

◆ clone()

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

Make a copy of the present type of IPropertySettings.

Implements Mantid::Kernel::IPropertySettings.

Definition at line 78 of file SetDefaultWhenProperty.cpp.

◆ dependsOn()

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

Other properties that this property depends on.

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 72 of file SetDefaultWhenProperty.cpp.

References m_watchedPropName.

◆ isConditionChanged()

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

Return true when change criterion should be tested.

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 changed property is the property that we are watching

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 36 of file SetDefaultWhenProperty.cpp.

References m_watchedPropName, and UNUSED_ARG.

Member Data Documentation

◆ m_changeCriterion

std::function<bool(const Mantid::Kernel::IPropertyManager *, Property *, Property *)> Mantid::Kernel::SetDefaultWhenProperty::m_changeCriterion
private

Criterion to determine if a new dynamic-default value should be set: in which case this function should modify the current property's value and return True, otherwise it should return False.

Definition at line 50 of file SetDefaultWhenProperty.h.

Referenced by applyChanges().

◆ m_watchedPropName

std::string Mantid::Kernel::SetDefaultWhenProperty::m_watchedPropName
private

Name of the watched property.

Definition at line 45 of file SetDefaultWhenProperty.h.

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


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