|
Mantid
|
The concrete, templated class for properties. More...
#include <PropertyWithValue.h>
Public Member Functions | |
| std::vector< std::string > | allowedValues () const override |
| Returns the set of valid values for this property, if such a set exists. | |
| PropertyWithValue< TYPE > * | clone () const override |
| 'Virtual copy constructor' | |
| std::string | getDefault () const override |
| Get the value the property was initialised with -its default value. | |
| IValidator_sptr | getValidator () const |
| Returns the validator as a constant variable so it cannot be changed. | |
| bool | isDefault () const override |
| Indicates if the property's value is the same as it was when it was set N.B. | |
| bool | isMultipleSelectionAllowed () override |
| Returns the set of valid values for this property, if such a set exists. | |
| std::string | isValid () const override |
| Check the value chosen for the property is OK, unless overidden it just calls the validator's isValid() N.B. | |
| virtual | operator const TYPE & () const |
| Allows you to get the value of the property simply by typing its name. | |
| bool | operator!= (const PropertyWithValue< TYPE > &rhs) const |
| Deep comparison (not equal). | |
| virtual const TYPE & | operator() () const |
| Allows you to get the value of the property via an expression like myProperty() | |
| PropertyWithValue & | operator+= (Property const *right) override |
| Add the value of another property. | |
| PropertyWithValue & | operator= (const PropertyWithValue &right) |
| Copy assignment operator assigns only the value and the validator not the name, default (initial) value, etc. | |
| virtual PropertyWithValue & | operator= (const TYPE &value) |
| Assignment operator. | |
| bool | operator== (const PropertyWithValue< TYPE > &rhs) const |
| Deep comparison. | |
| PropertyWithValue ()=delete | |
| PropertyWithValue (const PropertyWithValue< TYPE > &right) | |
| Copy constructor Note the default value of the copied object is the initial value of original. | |
| PropertyWithValue (const std::string &name, const TYPE &defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, const unsigned int direction) | |
| Constructor. | |
| PropertyWithValue (std::string name, TYPE defaultValue, const unsigned int direction) | |
| Constructor. | |
| PropertyWithValue (std::string name, TYPE defaultValue, IValidator_sptr validator=IValidator_sptr(new NullValidator), const unsigned int direction=Direction::Input) | |
| Constructor. | |
| virtual void | replaceValidator (IValidator_sptr newValidator) |
| Replace the current validator with the given one. | |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| MANTID_KERNEL_DLL void | saveProperty (Nexus::File *file) |
| void | saveProperty (Nexus::File *file) override |
| std::string | setDataItem (const std::shared_ptr< DataItem > &data) override |
| Set a property value via a DataItem. | |
| std::string | setValue (const std::string &value) override |
| Set the value of the property from a string representation. | |
| std::string | setValueFromJson (const Json::Value &value) override |
| Set the value of the property from a Json representation. | |
| int | size () const override |
| Get the size of the property. | |
| std::string | value () const override |
| Get the value of the property as a string. | |
| Json::Value | valueAsJson () const override |
| Attempt to construct a Json::Value object from the plain value. | |
| std::string | valueAsPrettyStr (const size_t maxLength=0, const bool collapseLists=true) const override |
| Get the value of the property as a string. | |
Public Member Functions inherited from Mantid::Kernel::Property | |
| bool | autoTrim () const |
| Returns if the property is set to automatically trim string unput values of whitespace. | |
| void | clearSettings () |
| Deletes the PropertySettings object contained. | |
| virtual const PropertyHistory | createHistory () const |
| Create a PropertyHistory object representing the current state of the Property. | |
| void | createTemporaryValue () |
| Create a temporary value for this property. | |
| unsigned int | direction () const |
| returns the direction of the property | |
| bool | disableReplaceWSButton () const |
| Returns if the property is set to disable the creation of the "Replace Workspace" button. | |
| const std::string & | documentation () const |
| Get the property's documentation string. | |
| const std::string & | getGroup () |
| virtual size_t | getMemorySize () const |
| IPropertySettings * | getSettings () |
| const IPropertySettings * | getSettings () const |
| bool | hasTemporaryValue () const |
| Property is using a temporary value for this property. | |
| bool | isDynamicDefault () const |
| Returns a flag indicating that the property's value has been set programmatically, for example, if the property has a default value which depends on the value of an upstream property. | |
| virtual bool | isValueSerializable () const |
| Whether the string returned by value() can be used for serialization. | |
| virtual Property & | merge (Property *) |
| Just returns the property (*this) unless overridden. | |
| const std::string & | name () const |
| Get the property's name. | |
| bool | remember () const |
| Whether to save input values. | |
| void | setAutoTrim (const bool &setting) |
| Sets if the property is set to automatically trim string unput values of whitespace. | |
| void | setDisableReplaceWSButton (const bool &disable) |
| Sets the property to disable the creation of the "Replace Workspace" button. | |
| void | setDocumentation (const std::string &documentation) |
| Sets the user level description of the property. | |
| void | setGroup (const std::string &group) |
| Set the group this property belongs to. | |
| void | setIsDynamicDefault (const bool &flag) |
| Set or clear the flag indicating whether or not the property's value has been set programmatically. | |
| void | setName (const std::string &name) |
| Set the property's name. | |
| void | setRemember (bool) |
| Set wheter to remeber this property input. | |
| void | setSettings (std::unique_ptr< IPropertySettings > settings) |
| Set the PropertySettings object. | |
| virtual void | setUnits (const std::string &unit) |
| Sets the units of the property, as a string. | |
| const std::string | type () const |
| Returns the type of the property as a string. | |
| const std::type_info * | type_info () const |
| Get the property type_info. | |
| virtual const std::string & | units () const |
| Returns the units of the property, if any, as a string. | |
| virtual | ~Property () |
| Virtual destructor. | |
Protected Attributes | |
| TYPE | m_initialValue |
| the property's default value which is also its initial value | |
| TYPE | m_value |
| The value of the property. | |
Protected Attributes inherited from Mantid::Kernel::Property | |
| std::string | m_name |
| The name of the property. | |
Private Member Functions | |
| const TYPE | getValueForAlias (const TYPE &alias) const |
| Return value for a given alias. | |
| template<typename U > | |
| std::string | setTypedValue (const U &value, const std::false_type &) |
| Helper function for setValue(DataItem_sptr). | |
| template<typename U > | |
| std::string | setTypedValue (const U &value, const std::true_type &) |
| Helper function for setValue(DataItem_sptr). | |
| std::string | setValueFromProperty (const Property &right) override |
| Set the value of the property via a reference to another property. | |
Private Attributes | |
| IValidator_sptr | m_validator |
| Visitor validator class. | |
Static Private Attributes | |
| static Logger | g_logger |
| Static reference to the logger class. | |
Additional Inherited Members | |
Protected Member Functions inherited from Mantid::Kernel::Property | |
| Property (const Property &right) | |
| Copy constructor. | |
| Property (std::string name, const std::type_info &type, const unsigned int &direction=Direction::Input) | |
| Constructor. | |
The concrete, templated class for properties.
The supported types at present are int, double, bool & std::string.
With reference to the Gaudi structure, this class can be seen as the equivalent of both the Gaudi class of the same name and its sub-classses.
Definition at line 32 of file PropertyWithValue.h.
| Mantid::Kernel::PropertyWithValue< TYPE >::PropertyWithValue | ( | std::string | name, |
| TYPE | defaultValue, | ||
| IValidator_sptr | validator = IValidator_sptr(new NullValidator), |
||
| const unsigned int | direction = Direction::Input |
||
| ) |
Constructor.
| name | :: The name to assign to the property |
| defaultValue | :: Is stored initial default value of the property |
| validator | :: The validator to use for this property |
| direction | :: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) property |
Definition at line 44 of file PropertyWithValue.hxx.
| Mantid::Kernel::PropertyWithValue< TYPE >::PropertyWithValue | ( | std::string | name, |
| TYPE | defaultValue, | ||
| const unsigned int | direction | ||
| ) |
Constructor.
| name | :: The name to assign to the property |
| defaultValue | :: Is stored initial default value of the property |
| direction | :: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) property |
Definition at line 56 of file PropertyWithValue.hxx.
| Mantid::Kernel::PropertyWithValue< TYPE >::PropertyWithValue | ( | const std::string & | name, |
| const TYPE & | defaultValue, | ||
| const std::string & | defaultValueStr, | ||
| IValidator_sptr | validator, | ||
| const unsigned int | direction | ||
| ) |
Constructor.
| name | :: The name to assign to the property. |
| defaultValue | :: A vector of numerical type, empty to comply with other definitions. |
| defaultValueStr | :: The numerical values you wish to assign to the property |
| validator | :: The validator to use for this property |
| direction | :: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) property |
Definition at line 75 of file PropertyWithValue.hxx.
| Mantid::Kernel::PropertyWithValue< TYPE >::PropertyWithValue | ( | const PropertyWithValue< TYPE > & | right | ) |
Copy constructor Note the default value of the copied object is the initial value of original.
Definition at line 88 of file PropertyWithValue.hxx.
|
delete |
References Mantid::API::operator+=().
|
overridevirtual |
Returns the set of valid values for this property, if such a set exists.
If not, it returns an empty vector.
Reimplemented from Mantid::Kernel::Property.
Definition at line 318 of file PropertyWithValue.hxx.
References Mantid::Kernel::determineAllowedValues(), m_validator, and m_value.
Referenced by MantidQt::API::FileFinderWidget::getFileExtensionsFromAlgorithm().
|
overridevirtual |
'Virtual copy constructor'
Implements Mantid::Kernel::Property.
Definition at line 94 of file PropertyWithValue.hxx.
|
overridevirtual |
Get the value the property was initialised with -its default value.
Implements Mantid::Kernel::Property.
Definition at line 159 of file PropertyWithValue.hxx.
References Mantid::Kernel::toString().
| IValidator_sptr Mantid::Kernel::PropertyWithValue< TYPE >::getValidator | ( | ) | const |
Returns the validator as a constant variable so it cannot be changed.
| TYPE | :: The type of the property value |
Definition at line 412 of file PropertyWithValue.hxx.
References m_validator.
|
private |
Return value for a given alias.
| alias | :: An alias for a value. If a value cannot be found throw an invalid_argument exception. |
Definition at line 400 of file PropertyWithValue.hxx.
References m_validator, Mantid::Kernel::toString(), and Mantid::Kernel::toValue().
|
overridevirtual |
Indicates if the property's value is the same as it was when it was set N.B.
Uses an unsafe comparison in the case of doubles, consider overriding if the value is a pointer or floating point type
Implements Mantid::Kernel::Property.
Definition at line 311 of file PropertyWithValue.hxx.
References m_value.
|
overridevirtual |
Returns the set of valid values for this property, if such a set exists.
If not, it returns an empty vector.
Reimplemented from Mantid::Kernel::Property.
Definition at line 327 of file PropertyWithValue.hxx.
References m_validator.
|
overridevirtual |
Check the value chosen for the property is OK, unless overidden it just calls the validator's isValid() N.B.
Problems found in validator are written to the log if you this function to do checking outside a validator may want to do more logging
Reimplemented from Mantid::Kernel::Property.
Definition at line 303 of file PropertyWithValue.hxx.
References Mantid::Kernel::PropertyWithValue< TYPE >::isValid(), m_validator, and m_value.
Referenced by Mantid::API::FileProperty::isValid(), Mantid::Kernel::PropertyWithValue< TYPE >::isValid(), and Mantid::Algorithms::ExtractMaskToTable::parseStringToVector().
|
virtual |
Allows you to get the value of the property simply by typing its name.
Means you can use an expression like: int i = myProperty;
Definition at line 294 of file PropertyWithValue.hxx.
References m_value.
| bool Mantid::Kernel::PropertyWithValue< TYPE >::operator!= | ( | const PropertyWithValue< TYPE > & | rhs | ) | const |
Deep comparison (not equal).
| rhs | The other property to compare to. |
Definition at line 148 of file PropertyWithValue.hxx.
References rhs.
|
virtual |
Allows you to get the value of the property via an expression like myProperty()
Definition at line 288 of file PropertyWithValue.hxx.
References m_value.
|
overridevirtual |
Add the value of another property.
| right | the property to add |
Implements Mantid::Kernel::Property.
Definition at line 238 of file PropertyWithValue.hxx.
References Mantid::Kernel::addingOperator(), m_value, name, rhs, and right.
| PropertyWithValue< TYPE > & Mantid::Kernel::PropertyWithValue< TYPE >::operator= | ( | const PropertyWithValue< TYPE > & | right | ) |
Copy assignment operator assigns only the value and the validator not the name, default (initial) value, etc.
Definition at line 225 of file PropertyWithValue.hxx.
References m_validator, m_value, Mantid::Kernel::PropertyWithValue< TYPE >::m_value, and right.
|
virtual |
Assignment operator.
Allows assignment of a new value to the property by writing, e.g., myProperty = 3;
| value | :: The new value to assign to the property |
Reimplemented in Mantid::API::FunctionProperty, and Mantid::PythonInterface::PythonObjectProperty.
Definition at line 261 of file PropertyWithValue.hxx.
References m_value, name, Mantid::Kernel::toString(), Mantid::Kernel::toValue(), and value.
| bool Mantid::Kernel::PropertyWithValue< TYPE >::operator== | ( | const PropertyWithValue< TYPE > & | rhs | ) | const |
Deep comparison.
| rhs | The other property to compare to. |
Definition at line 137 of file PropertyWithValue.hxx.
References m_value, name, Mantid::Kernel::Property::name(), and rhs.
|
virtual |
Replace the current validator with the given one.
| newValidator | :: A replacement validator |
Definition at line 335 of file PropertyWithValue.hxx.
References m_validator.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
virtual |
Reimplemented from Mantid::Kernel::Property.
|
overridevirtual |
Reimplemented from Mantid::Kernel::Property.
Definition at line 98 of file PropertyWithValue.hxx.
References name.
|
overridevirtual |
Set a property value via a DataItem.
| data | :: A shared pointer to a data item |
Implements Mantid::Kernel::Property.
Definition at line 215 of file PropertyWithValue.hxx.
|
private |
Helper function for setValue(DataItem_sptr).
Uses boost type traits to ensure it is only used if U is NOT a type that is convertible to std::shared_ptr<DataItem>
| value | :: A object of type convertible to std::shared_ptr<DataItem> |
Definition at line 390 of file PropertyWithValue.hxx.
References name, UNUSED_ARG, and value.
|
private |
Helper function for setValue(DataItem_sptr).
Uses boost type traits to ensure it is only used if U is a type that is convertible to std::shared_ptr<DataItem>
| value | :: A object of type convertible to std::shared_ptr<DataItem> |
Definition at line 365 of file PropertyWithValue.hxx.
|
overridevirtual |
Set the value of the property from a string representation.
Note that "1" & "0" must be used for bool properties rather than true/false.
| value | :: The value to assign to the property |
Implements Mantid::Kernel::Property.
Definition at line 168 of file PropertyWithValue.hxx.
References error, m_value, name, Mantid::Kernel::toValue(), and value.
Referenced by Mantid::API::FileProperty::setLoadProperty(), Mantid::API::FileProperty::setSaveProperty(), Mantid::API::FileProperty::setValue(), and Mantid::Algorithms::ChangeTimeZero::shiftTimeOfLogForStringProperty().
|
overridevirtual |
Set the value of the property from a Json representation.
| value | :: The value to assign to the property |
Implements Mantid::Kernel::Property.
Definition at line 196 of file PropertyWithValue.hxx.
References value.
|
overrideprivatevirtual |
Set the value of the property via a reference to another property.
If the value is unacceptable the value is not changed but a string is returned. The value is only accepted if the other property has the same type as this
| right | :: A reference to a property. |
Implements Mantid::Kernel::Property.
Definition at line 346 of file PropertyWithValue.hxx.
|
overridevirtual |
Get the size of the property.
Reimplemented from Mantid::Kernel::Property.
Definition at line 154 of file PropertyWithValue.hxx.
References Mantid::Kernel::findSize(), and m_value.
Referenced by Mantid::Algorithms::MaskBinsFromTable::convertToSpectraList(), and Mantid::Algorithms::ExtractMaskToTable::parseStringToVector().
|
overridevirtual |
Get the value of the property as a string.
Implements Mantid::Kernel::Property.
Definition at line 109 of file PropertyWithValue.hxx.
References m_value, and Mantid::Kernel::toString().
Referenced by Mantid::Algorithms::ChangeTimeZero::shiftTimeOfLogForStringProperty().
|
overridevirtual |
Attempt to construct a Json::Value object from the plain value.
Implements Mantid::Kernel::Property.
Definition at line 130 of file PropertyWithValue.hxx.
References Mantid::Kernel::encodeAsJson().
|
overridevirtual |
Get the value of the property as a string.
Reimplemented from Mantid::Kernel::Property.
Definition at line 115 of file PropertyWithValue.hxx.
References m_value, Mantid::Kernel::Strings::shorten(), Mantid::Kernel::toPrettyString(), and value.
|
staticprivate |
Static reference to the logger class.
Definition at line 86 of file PropertyWithValue.h.
|
protected |
the property's default value which is also its initial value
Definition at line 71 of file PropertyWithValue.h.
|
private |
Visitor validator class.
Definition at line 83 of file PropertyWithValue.h.
|
protected |
The value of the property.
Definition at line 68 of file PropertyWithValue.h.
Referenced by Mantid::API::IndexProperty::getFilteredIndexInfo(), Mantid::API::IndexProperty::getIndices(), Mantid::API::IndexProperty::isDefault(), and Mantid::Kernel::PropertyWithValue< TYPE >::operator=().