Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::API::AlgorithmProperty Class Reference

Define an algorithm property that can be used to supply an algorithm object to a subsequent algorithm. More...

#include <AlgorithmProperty.h>

Inheritance diagram for Mantid::API::AlgorithmProperty:
Mantid::Kernel::PropertyWithValue< std::shared_ptr< IAlgorithm > > Mantid::Kernel::Property

Public Types

using HeldType = std::shared_ptr< IAlgorithm >
 Typedef the held type.
 

Public Member Functions

 AlgorithmProperty (const AlgorithmProperty &)=default
 
 AlgorithmProperty (const std::string &propName, Kernel::IValidator_sptr validator=Kernel::IValidator_sptr(new Kernel::NullValidator), unsigned int direction=Kernel::Direction::Input)
 Constructor.
 
AlgorithmPropertyclone () const override
 'Virtual copy constructor'
 
std::string getDefault () const override
 Get the default.
 
AlgorithmPropertyoperator+= (Kernel::Property const *) override
 Add the value of another property. Doesn't make sense here.
 
std::string setValue (const std::string &value) override
 Sets the value of the algorithm from a string representation.
 
std::string setValueFromJson (const Json::Value &value) override
 Sets the value of the algorithm from a Json representation.
 
std::string value () const override
 Return the algorithm as string.
 
Json::Value valueAsJson () const override
 Create a Json::Value from the algorithm value.
 
- Public Member Functions inherited from Mantid::Kernel::PropertyWithValue< std::shared_ptr< IAlgorithm > >
std::vector< std::string > allowedValues () const override
 Returns the set of valid values for this property, if such a set exists.
 
PropertyWithValue< std::shared_ptr< IAlgorithm > > * 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 std::shared_ptr< IAlgorithm > & () const
 Allows you to get the value of the property simply by typing its name.
 
bool operator!= (const PropertyWithValue< std::shared_ptr< IAlgorithm > > &rhs) const
 Deep comparison (not equal).
 
virtual const std::shared_ptr< IAlgorithm > & operator() () const
 Allows you to get the value of the property via an expression like myProperty()
 
PropertyWithValueoperator+= (Property const *right) override
 Add the value of another property.
 
PropertyWithValueoperator= (const PropertyWithValue &right)
 Copy assignment operator assigns only the value and the validator not the name, default (initial) value, etc.
 
virtual PropertyWithValueoperator= (const std::shared_ptr< IAlgorithm > &value)
 Assignment operator.
 
bool operator== (const PropertyWithValue< std::shared_ptr< IAlgorithm > > &rhs) const
 Deep comparison.
 
 PropertyWithValue ()=delete
 
 PropertyWithValue (const PropertyWithValue< std::shared_ptr< IAlgorithm > > &right)
 Copy constructor Note the default value of the copied object is the initial value of original.
 
 PropertyWithValue (const std::string &name, const std::shared_ptr< IAlgorithm > &defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, const unsigned int direction)
 Constructor.
 
 PropertyWithValue (std::string name, std::shared_ptr< IAlgorithm > defaultValue, const unsigned int direction)
 Constructor.
 
 PropertyWithValue (std::string name, std::shared_ptr< IAlgorithm > 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
 
IPropertySettingsgetSettings ()
 
const IPropertySettingsgetSettings () 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 Propertymerge (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.
 

Private Member Functions

std::string setBaseValue (const HeldType &algm)
 Set the value from the algorithm pointer.
 

Private Attributes

std::string m_algmStr
 

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< std::shared_ptr< IAlgorithm > >
std::shared_ptr< IAlgorithmm_initialValue
 the property's default value which is also its initial value
 
std::shared_ptr< IAlgorithmm_value
 The value of the property.
 
- Protected Attributes inherited from Mantid::Kernel::Property
std::string m_name
 The name of the property.
 

Detailed Description

Define an algorithm property that can be used to supply an algorithm object to a subsequent algorithm.

It is a specialized version of PropertyWithValue where the type a pointer to an object implementing the API::IAlgorithm interface.

Author
Martyn Gigg, Tessella Plc
Date
24/03/2011

Definition at line 39 of file AlgorithmProperty.h.

Member Typedef Documentation

◆ HeldType

Typedef the held type.

Definition at line 42 of file AlgorithmProperty.h.

Constructor & Destructor Documentation

◆ AlgorithmProperty() [1/2]

Mantid::API::AlgorithmProperty::AlgorithmProperty ( const std::string &  propName,
Kernel::IValidator_sptr  validator = Kernel::IValidator_sptr(new Kernel::NullValidator),
unsigned int  direction = Kernel::Direction::Input 
)

Constructor.

Parameters
propName:: The name to assign to the property
validator:: The validator to use for this property (this class will take ownership of the validator)
direction:: Whether this is a Direction::Input, Direction::Output or Direction::InOut (Input & Output) property

Definition at line 32 of file AlgorithmProperty.cpp.

◆ AlgorithmProperty() [2/2]

Mantid::API::AlgorithmProperty::AlgorithmProperty ( const AlgorithmProperty )
default

Member Function Documentation

◆ clone()

AlgorithmProperty * Mantid::API::AlgorithmProperty::clone ( ) const
inlineoverridevirtual

'Virtual copy constructor'

Implements Mantid::Kernel::Property.

Definition at line 55 of file AlgorithmProperty.h.

◆ getDefault()

std::string Mantid::API::AlgorithmProperty::getDefault ( ) const
overridevirtual

Get the default.

Returns
An empty string

Implements Mantid::Kernel::Property.

Definition at line 51 of file AlgorithmProperty.cpp.

◆ operator+=()

AlgorithmProperty & Mantid::API::AlgorithmProperty::operator+= ( Kernel::Property const *  )
inlineoverridevirtual

Add the value of another property. Doesn't make sense here.

Implements Mantid::Kernel::Property.

Definition at line 58 of file AlgorithmProperty.h.

◆ setBaseValue()

std::string Mantid::API::AlgorithmProperty::setBaseValue ( const HeldType algm)
private

Set the value from the algorithm pointer.

Parameters
algm
Returns
An empty string if the value is valid, otherwise the string will contain the error

Definition at line 88 of file AlgorithmProperty.cpp.

References Mantid::Kernel::PropertyWithValue< std::shared_ptr< IAlgorithm > >::isValid(), and m_algmStr.

Referenced by setValue(), and setValueFromJson().

◆ setValue()

std::string Mantid::API::AlgorithmProperty::setValue ( const std::string &  value)
overridevirtual

Sets the value of the algorithm from a string representation.

Set value of the algorithm Attempts to create an Algorithm object.

Parameters
value:: The string format for an algorithm,
See also
Algorithm::toString
Returns
An empty string if the value is valid, otherwise the string will contain the error

Implements Mantid::Kernel::Property.

Definition at line 60 of file AlgorithmProperty.cpp.

References Mantid::API::Algorithm::fromString(), setBaseValue(), and value().

◆ setValueFromJson()

std::string Mantid::API::AlgorithmProperty::setValueFromJson ( const Json::Value &  value)
overridevirtual

Sets the value of the algorithm from a Json representation.

Set the value of the algorithm property from a Json value.

Parameters
valueA reference
Returns
An empty string if the value is valid, otherwise the string will contain the error

Implements Mantid::Kernel::Property.

Definition at line 74 of file AlgorithmProperty.cpp.

References Mantid::API::Algorithm::fromJson(), setBaseValue(), and value().

◆ value()

std::string Mantid::API::AlgorithmProperty::value ( ) const
overridevirtual

Return the algorithm as string.

Returns
The algorithm serialized as a string

Implements Mantid::Kernel::Property.

Definition at line 40 of file AlgorithmProperty.cpp.

References m_algmStr.

Referenced by setValue(), and setValueFromJson().

◆ valueAsJson()

Json::Value Mantid::API::AlgorithmProperty::valueAsJson ( ) const
overridevirtual

Create a Json::Value from the algorithm value.

Returns
A Json::Value objectValue encoding the algorithm

Implements Mantid::Kernel::Property.

Definition at line 45 of file AlgorithmProperty.cpp.

Member Data Documentation

◆ m_algmStr

std::string Mantid::API::AlgorithmProperty::m_algmStr
private

Definition at line 76 of file AlgorithmProperty.h.

Referenced by setBaseValue(), and value().


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