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

void applyChanges (const Mantid::Kernel::IPropertyManager *algo, Kernel::Property *const pProp) override
 If a new value should be set, the change is applied here. More...
 
IPropertySettingsclone () const override
 Make a copy of the present type of IPropertySettings. More...
 
std::string getPropertyValue (const IPropertyManager *algo) const
 Checks the algorithm and property are both valid and attempts to get the value associated with the property. More...
 
bool isConditionChanged (const IPropertyManager *algo, const std::string &changedPropName) const override
 Return true always. More...
 
void modify_allowed_values (Property *const)
 Stub function to satisfy the interface. More...
 
 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. More...
 
- Public Member Functions inherited from Mantid::Kernel::IPropertySettings
virtual void applyChanges (const IPropertyManager *, Property *const)
 The function user have to overload it in their custom code to modify the property according to the changes to other properties. More...
 
virtual IPropertySettingsclone () const =0
 Make a copy of the present type of IPropertySettings. More...
 
 IPropertySettings ()=default
 Constructor. More...
 
virtual bool isConditionChanged (const IPropertyManager *algo, const std::string &changedPropName="") const
 to verify if the properties, this one depends on have changed or other special condition occurs which needs the framework to react to More...
 
virtual bool isEnabled (const IPropertyManager *algo) const
 Is the property to be shown as "enabled" in the GUI. More...
 
virtual bool isVisible (const IPropertyManager *algo) const
 Is the property to be shown in the GUI? Default true. More...
 
virtual ~IPropertySettings ()=default
 Destructor. More...
 

Private Attributes

std::function< std::string(std::string, std::string)> m_changeCriterion
 Function to check if changes should be applied. More...
 
std::string m_watchedPropName
 Name of the watched property, based on which we may set the value of the current property. More...
 

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()

void Mantid::Kernel::SetValueWhenProperty::applyChanges ( const Mantid::Kernel::IPropertyManager algo,
Kernel::Property *const  pProp 
)
overridevirtual

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

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 65 of file SetValueWhenProperty.cpp.

References getPropertyValue(), m_changeCriterion, Mantid::Kernel::Property::setValue(), and Mantid::Kernel::Property::value().

◆ clone()

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

Make a copy of the present type of IPropertySettings.

Implements Mantid::Kernel::IPropertySettings.

Definition at line 75 of file SetValueWhenProperty.cpp.

◆ getPropertyValue()

std::string Mantid::Kernel::SetValueWhenProperty::getPropertyValue ( const IPropertyManager algo) const

Checks the algorithm and property are both valid and attempts to get the value associated with the property.

Checks the algorithm given is in a valid state and the property exists then proceeds to try to get the value associated.

Parameters
algo:: The pointer to the algorithm to process
Returns
:: The value contained by said property
Exceptions
:Throws if anything is wrong with the property or algorithm

Definition at line 31 of file SetValueWhenProperty.cpp.

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

Referenced by applyChanges().

◆ isConditionChanged()

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

Return true always.

Always returns true as SetValueWhenProperty always wants to check if the property it depends on has changed.

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

Reimplemented from Mantid::Kernel::IPropertySettings.

Definition at line 55 of file SetValueWhenProperty.cpp.

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

◆ modify_allowed_values()

void Mantid::Kernel::SetValueWhenProperty::modify_allowed_values ( Property * const  )

Stub function to satisfy the interface.

Does nothing in this case and put here to satisfy the interface.

Definition at line 73 of file SetValueWhenProperty.cpp.

Member Data Documentation

◆ m_changeCriterion

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

Function to check if changes should be applied.

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, based on which we may set the value of the current property.

Definition at line 48 of file SetValueWhenProperty.h.

Referenced by getPropertyValue(), and isConditionChanged().


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