|
Mantid
|
A property class for workspaces. More...
#include <WorkspaceProperty.h>
Public Member Functions | |
| std::vector< std::string > | allowedValues () const override |
| Returns the current contents of the AnalysisDataService for input workspaces. | |
| WorkspaceProperty< TYPE > * | clone () const override |
| 'Virtual copy constructor' | |
| const Kernel::PropertyHistory | createHistory () const override |
| Create a history record. | |
| std::string | getDefault () const override |
| Get the value the property was initialised with -its default value. | |
| Workspace_sptr | getWorkspace () const override |
| Get a pointer to the workspace. | |
| bool | isDefault () const override |
| Indicates if the object is still pointing to the same workspace. | |
| bool | isLocking () const override |
| Does the workspace need to be locked before starting an algorithm? | |
| bool | isOptional () const override |
| Is the workspace property optional. | |
| std::string | isValid () const override |
| Checks whether the entered workspace is valid. | |
| bool | isValueSerializable () const override |
| Returns true if the workspace is in the ADS or there is none. | |
| WorkspaceProperty & | operator+= (Kernel::Property const *) override |
| Add the value of another property. | |
| WorkspaceProperty & | operator= (const std::shared_ptr< TYPE > &value) override |
| Bring in the PropertyWithValue assignment operator explicitly (avoids VSC++ warning) | |
| WorkspaceProperty & | operator= (const WorkspaceProperty &right) |
| Copy assignment operator. | |
| std::string | setDataItem (const std::shared_ptr< Kernel::DataItem > &value) override |
| Set a value from a data item. | |
| void | setPropertyMode (const PropertyMode::Type &optional) override |
| Set the property mode of the property e.g. | |
| std::string | setValue (const std::string &value) override |
| Set the name of the workspace. | |
| std::string | setValueFromJson (const Json::Value &value) override |
| Set the name of the workspace from a Json::Value object Also tries to retrieve it from the AnalysisDataService. | |
| bool | store () override |
| If this is an output workspace, store it into the AnalysisDataService. | |
| std::string | value () const override |
| Get the name of the workspace. | |
| Json::Value | valueAsJson () const override |
| WorkspaceProperty (const std::string &name, const std::string &wsName, const unsigned int direction, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator)) | |
| Constructor. | |
| WorkspaceProperty (const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator)) | |
| Constructor. | |
| WorkspaceProperty (const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, const LockMode::Type locking, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator)) | |
| Constructor. | |
| WorkspaceProperty (const WorkspaceProperty &right) | |
| Copy constructor, the default name stored in the new object is the same as the default name from the original object. | |
Public Member Functions inherited from Mantid::Kernel::PropertyWithValue< TYPE > | |
| 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. | |
| 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 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. | |
Public Member Functions inherited from Mantid::API::IWorkspaceProperty | |
| virtual | ~IWorkspaceProperty ()=default |
| Virtual destructor. | |
Private Member Functions | |
| void | clear () override |
| Reset the pointer to the workspace. | |
| std::string | isOptionalWs () const |
| Checks whether the entered workspace (that by this point we've found is not in the ADS) is actually an optional workspace and so still valid. | |
| std::string | isValidGroup (const std::shared_ptr< WorkspaceGroup > &wsGroup) const |
| Checks whether the entered workspace group is valid. | |
| std::string | isValidOutputWs () const |
| Checks whether the entered output workspace is valid. | |
| void | retrieveWorkspaceFromADS () |
| Attempts to retreive the data from the ADS if the data is not foung the internal pointer is set to null. | |
Private Attributes | |
| std::string | m_initialWSName |
| The name of the workspace that the this this object was created for. | |
| LockMode::Type | m_locking |
| A flag indicating whether the workspace should be read or write-locked when an algorithm begins. | |
| PropertyMode::Type | m_optional |
| A flag indicating whether the property should be considered optional. | |
| std::string | m_workspaceName |
| The name of the workspace (as used by the AnalysisDataService) | |
Static Private Attributes | |
| static Kernel::Logger | g_log |
| for access to logging streams | |
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. | |
Protected Attributes inherited from Mantid::Kernel::PropertyWithValue< TYPE > | |
| 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. | |
A property class for workspaces.
Inherits from PropertyWithValue, with the value being a pointer to the workspace type given to the WorkspaceProperty constructor. This kind of property also holds the name of the workspace (as used by the AnalysisDataService) and an indication of whether it is an input or output to an algorithm (or both).
The pointers to the workspaces are fetched from the ADS when the properties are validated (i.e. when the PropertyManager::validateProperties() method calls isValid() ). Pointers to output workspaces are also fetched, if they exist, and can then be used within an algorithm. (An example of when this might be useful is if the user wants to write the output into the same workspace as is used for input - this avoids creating a new workspace and the overwriting the old one at the end.)
Definition at line 51 of file WorkspaceProperty.h.
|
explicit |
Constructor.
Sets the property and workspace names but initializes the workspace pointer to null.
| name | :: The name to assign to the property |
| wsName | :: The name of the workspace |
| direction | :: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) workspace |
| validator | :: The (optional) validator to use for this property |
| std::out_of_range | if the direction argument is not a member of the Direction enum (i.e. 0-2) |
Definition at line 34 of file WorkspaceProperty.hxx.
|
explicit |
Constructor.
Sets the property and workspace names but initializes the workspace pointer to null.
| name | :: The name to assign to the property |
| wsName | :: The name of the workspace |
| direction | :: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) workspace |
| optional | :: If true then the property is optional |
| validator | :: The (optional) validator to use for this property |
| std::out_of_range | if the direction argument is not a member of the Direction enum (i.e. 0-2) |
Definition at line 53 of file WorkspaceProperty.hxx.
|
explicit |
Constructor.
Sets the property and workspace names but initializes the workspace pointer to null.
| name | :: The name to assign to the property |
| wsName | :: The name of the workspace |
| direction | :: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) workspace |
| optional | :: A boolean indicating whether the property is mandatory or not. Only matters for input properties |
| locking | :: A boolean indicating whether the workspace should read or write-locked when an algorithm begins. Default=true. |
| validator | :: The (optional) validator to use for this property |
| std::out_of_range | if the direction argument is not a member of the Direction enum (i.e. 0-2) |
Definition at line 76 of file WorkspaceProperty.hxx.
| Mantid::API::WorkspaceProperty< TYPE >::WorkspaceProperty | ( | const WorkspaceProperty< TYPE > & | right | ) |
Copy constructor, the default name stored in the new object is the same as the default name from the original object.
Definition at line 85 of file WorkspaceProperty.hxx.
|
overridevirtual |
Returns the current contents of the AnalysisDataService for input workspaces.
For output workspaces, an empty set is returned
Reimplemented from Mantid::Kernel::Property.
Definition at line 278 of file WorkspaceProperty.hxx.
References Mantid::Kernel::Direction::InOut, Mantid::Kernel::Direction::Input, and Mantid::Kernel::Sorted.
|
overrideprivatevirtual |
Reset the pointer to the workspace.
Implements Mantid::API::IWorkspaceProperty.
Definition at line 443 of file WorkspaceProperty.hxx.
References m_value.
|
overridevirtual |
'Virtual copy constructor'
Implements Mantid::Kernel::Property.
Definition at line 120 of file WorkspaceProperty.hxx.
|
overridevirtual |
Create a history record.
Reimplemented from Mantid::Kernel::Property.
Definition at line 304 of file WorkspaceProperty.hxx.
|
overridevirtual |
Get the value the property was initialised with -its default value.
Implements Mantid::Kernel::Property.
Definition at line 144 of file WorkspaceProperty.hxx.
|
overridevirtual |
Get a pointer to the workspace.
Implements Mantid::API::IWorkspaceProperty.
Definition at line 350 of file WorkspaceProperty.hxx.
Referenced by Mantid::API::Algorithm::checkGroups().
|
overridevirtual |
Indicates if the object is still pointing to the same workspace.
Implements Mantid::Kernel::Property.
Definition at line 257 of file WorkspaceProperty.hxx.
References m_value.
|
overridevirtual |
Does the workspace need to be locked before starting an algorithm?
Implements Mantid::API::IWorkspaceProperty.
Definition at line 271 of file WorkspaceProperty.hxx.
References Mantid::API::LockMode::Lock.
|
overridevirtual |
Is the workspace property optional.
Implements Mantid::API::IWorkspaceProperty.
Definition at line 266 of file WorkspaceProperty.hxx.
References Mantid::API::PropertyMode::Optional.
|
private |
Checks whether the entered workspace (that by this point we've found is not in the ADS) is actually an optional workspace and so still valid.
Definition at line 426 of file WorkspaceProperty.hxx.
|
overridevirtual |
Checks whether the entered workspace is valid.
To be valid, in addition to satisfying the conditions of any validators, an output property must not have an empty name and an input one must point to a workspace of the correct type.
Reimplemented from Mantid::Kernel::Property.
Definition at line 212 of file WorkspaceProperty.hxx.
References error, Mantid::Kernel::Direction::InOut, Mantid::Kernel::Direction::Input, m_value, Mantid::Kernel::Direction::Output, and value.
|
private |
Checks whether the entered workspace group is valid.
To be valid all members of the group have to be valid.
| wsGroup | :: the WorkspaceGroup of which to check the validity |
Definition at line 358 of file WorkspaceProperty.hxx.
References Mantid::Kernel::Logger::debug(), error, Mantid::API::g_log, and Mantid::API::WorkspaceProperty< TYPE >::setValue().
|
private |
Checks whether the entered output workspace is valid.
To be valid the only thing it needs is a name that is allowed by the ADS,
Definition at line 406 of file WorkspaceProperty.hxx.
|
overridevirtual |
Returns true if the workspace is in the ADS or there is none.
Reimplemented from Mantid::Kernel::Property.
Definition at line 137 of file WorkspaceProperty.hxx.
References m_value.
|
overridevirtual |
Add the value of another property.
Implements Mantid::Kernel::Property.
Definition at line 115 of file WorkspaceProperty.hxx.
|
override |
Bring in the PropertyWithValue assignment operator explicitly (avoids VSC++ warning)
| value | :: The value to set to |
Definition at line 104 of file WorkspaceProperty.hxx.
References Mantid::Kernel::Direction::Input, and value.
| WorkspaceProperty< TYPE > & Mantid::API::WorkspaceProperty< TYPE >::operator= | ( | const WorkspaceProperty< TYPE > & | right | ) |
Copy assignment operator.
Only copies the value (i.e. the pointer to the workspace)
Definition at line 91 of file WorkspaceProperty.hxx.
References right.
|
private |
Attempts to retreive the data from the ADS if the data is not foung the internal pointer is set to null.
Definition at line 450 of file WorkspaceProperty.hxx.
References m_value.
|
overridevirtual |
Set a value from a data item.
| value | :: A shared pointer to a DataItem. If it is of the correct type it will set validated, if not the property's value will be cleared. |
Implements Mantid::Kernel::Property.
Definition at line 182 of file WorkspaceProperty.hxx.
References Mantid::Kernel::Direction::Input, m_value, Mantid::Kernel::Direction::Output, and value.
|
overridevirtual |
Set the property mode of the property e.g.
Mandatory or Optional
| optional | :: Property mode Mandatory or Optional |
Implements Mantid::API::IWorkspaceProperty.
Definition at line 201 of file WorkspaceProperty.hxx.
|
overridevirtual |
Set the name of the workspace.
Also tries to retrieve it from the AnalysisDataService.
| value | :: The new name for the workspace |
Implements Mantid::Kernel::Property.
Definition at line 152 of file WorkspaceProperty.hxx.
References value.
Referenced by Mantid::API::WorkspaceProperty< TYPE >::isValidGroup().
|
overridevirtual |
Set the name of the workspace from a Json::Value object Also tries to retrieve it from the AnalysisDataService.
| value | :: The new name for the workspace |
Implements Mantid::Kernel::Property.
Definition at line 168 of file WorkspaceProperty.hxx.
References value.
|
overridevirtual |
If this is an output workspace, store it into the AnalysisDataService.
| std::runtime_error | if unable to store the workspace successfully |
Implements Mantid::API::IWorkspaceProperty.
Definition at line 329 of file WorkspaceProperty.hxx.
|
overridevirtual |
Get the name of the workspace.
Implements Mantid::Kernel::Property.
Definition at line 127 of file WorkspaceProperty.hxx.
Referenced by Mantid::CurveFitting::Algorithms::PlotPeakByLogValue::getMinimizerString().
|
overridevirtual |
Implements Mantid::Kernel::Property.
Definition at line 132 of file WorkspaceProperty.hxx.
References value.
|
staticprivate |
for access to logging streams
Definition at line 131 of file WorkspaceProperty.h.
|
private |
The name of the workspace that the this this object was created for.
Definition at line 122 of file WorkspaceProperty.h.
|
private |
A flag indicating whether the workspace should be read or write-locked when an algorithm begins.
Default=true.
Definition at line 128 of file WorkspaceProperty.h.
|
private |
A flag indicating whether the property should be considered optional.
Only matters for input workspaces
Definition at line 125 of file WorkspaceProperty.h.
|
private |
The name of the workspace (as used by the AnalysisDataService)
Definition at line 120 of file WorkspaceProperty.h.