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

A property class for functions. More...

#include <FunctionProperty.h>

Inheritance diagram for Mantid::API::FunctionProperty:
Mantid::Kernel::PropertyWithValue< std::shared_ptr< IFunction > > Mantid::Kernel::Property

Public Member Functions

FunctionPropertyclone () const override
 'Virtual copy constructor'
 
const Kernel::PropertyHistory createHistory () const override
 Create a history record.
 
 FunctionProperty (const FunctionProperty &right)=default
 Copy constructor.
 
 FunctionProperty (const std::string &name, const unsigned int direction=Kernel::Direction::Input, const PropertyMode::Type optional=PropertyMode::Type::Mandatory)
 Constructor.
 
std::string getDefault () const override
 Get the value the property was initialised with -its default value.
 
bool isDefault () const override
 Is default.
 
std::string isValid () const override
 Checks whether the entered function is valid.
 
FunctionPropertyoperator+= (Kernel::Property const *) override
 Add the value of another property.
 
FunctionPropertyoperator= (const FunctionProperty &right)=default
 Copy assignment operator.
 
FunctionPropertyoperator= (const std::shared_ptr< IFunction > &value) override
 Bring in the PropertyWithValue assignment operator explicitly (avoids VSC++ warning)
 
std::string setValue (const std::string &value) override
 Set the value of the property.
 
std::string setValueFromJson (const Json::Value &value) override
 Set the value of the property as a Json representation.
 
std::string value () const override
 Get the function definition string.
 
Json::Value valueAsJson () const override
 Return a Json::Value object encoding the function string.
 
- Public Member Functions inherited from Mantid::Kernel::PropertyWithValue< std::shared_ptr< IFunction > >
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< IFunction > > * 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< IFunction > & () const
 Allows you to get the value of the property simply by typing its name.
 
bool operator!= (const PropertyWithValue< std::shared_ptr< IFunction > > &rhs) const
 Deep comparison (not equal).
 
virtual const std::shared_ptr< IFunction > & 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.
 
bool operator== (const PropertyWithValue< std::shared_ptr< IFunction > > &rhs) const
 Deep comparison.
 
 PropertyWithValue ()=delete
 
 PropertyWithValue (const PropertyWithValue< std::shared_ptr< IFunction > > &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< IFunction > &defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, const unsigned int direction)
 Constructor.
 
 PropertyWithValue (std::string name, std::shared_ptr< IFunction > defaultValue, const unsigned int direction)
 Constructor.
 
 PropertyWithValue (std::string name, std::shared_ptr< IFunction > 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
 
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

bool isOptional () const
 Return true if the property is optional.
 

Private Attributes

std::string m_definition
 The function definition string (as used by the FunctionFactory)
 
PropertyMode::Type m_optional
 A flag indicating whether the property should be considered optional.
 

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

Detailed Description

A property class for functions.

Holds a shared pointer to a function. The string representation is the creation string accepted by the FunctionFactory.

Author
Roman Tolchenov, Tessella plc
Date
08/02/2012

Definition at line 29 of file FunctionProperty.h.

Constructor & Destructor Documentation

◆ FunctionProperty() [1/2]

Mantid::API::FunctionProperty::FunctionProperty ( const std::string &  name,
const unsigned int  direction = Kernel::Direction::Input,
const PropertyMode::Type  optional = PropertyMode::Type::Mandatory 
)

Constructor.

Sets the property names but initialises the function pointer to null.

Parameters
name:: The name to assign to the property
direction:: The direction of the function (i.e. input or output)
optional:: A flag indicating whether the property is optional or mandatory.

Definition at line 20 of file FunctionProperty.cpp.

◆ FunctionProperty() [2/2]

Mantid::API::FunctionProperty::FunctionProperty ( const FunctionProperty right)
default

Copy constructor.

Member Function Documentation

◆ clone()

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

'Virtual copy constructor'

Implements Mantid::Kernel::Property.

Definition at line 50 of file FunctionProperty.h.

◆ createHistory()

const Kernel::PropertyHistory Mantid::API::FunctionProperty::createHistory ( ) const
overridevirtual

Create a history record.

Returns
A populated PropertyHistory for this class

Reimplemented from Mantid::Kernel::Property.

Definition at line 125 of file FunctionProperty.cpp.

◆ getDefault()

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

Get the value the property was initialised with -its default value.

Returns
The default value

Implements Mantid::Kernel::Property.

Definition at line 61 of file FunctionProperty.cpp.

Referenced by value().

◆ isDefault()

bool Mantid::API::FunctionProperty::isDefault ( ) const
overridevirtual

Is default.

Indicates if the function has not been created yet.

Returns
true if the function has not been created yet.

Implements Mantid::Kernel::Property.

Definition at line 121 of file FunctionProperty.cpp.

References Mantid::Kernel::PropertyWithValue< std::shared_ptr< IFunction > >::m_value.

Referenced by isValid().

◆ isOptional()

bool Mantid::API::FunctionProperty::isOptional ( ) const
private

Return true if the property is optional.

Returns true if this property is optional.

Returns
true if this property is optional.

Definition at line 66 of file FunctionProperty.cpp.

References m_optional, and Mantid::API::PropertyMode::Optional.

Referenced by isValid(), and setValue().

◆ isValid()

std::string Mantid::API::FunctionProperty::isValid ( ) const
overridevirtual

Checks whether the entered function is valid.

To be valid it has to be other then default which is no function defined.

Returns
A user level description of the problem or "" if it is valid.

Reimplemented from Mantid::Kernel::Property.

Definition at line 110 of file FunctionProperty.cpp.

References Mantid::Kernel::Property::direction(), isDefault(), isOptional(), and Mantid::Kernel::Direction::Output.

◆ operator+=()

FunctionProperty & Mantid::API::FunctionProperty::operator+= ( Kernel::Property const *  )
overridevirtual

Add the value of another property.

Implements Mantid::Kernel::Property.

Definition at line 38 of file FunctionProperty.cpp.

◆ operator=() [1/2]

FunctionProperty & Mantid::API::FunctionProperty::operator= ( const FunctionProperty right)
default

Copy assignment operator.

Only copies the value (i.e. the pointer to the function)

References Mantid::API::operator+=().

◆ operator=() [2/2]

FunctionProperty & Mantid::API::FunctionProperty::operator= ( const std::shared_ptr< IFunction > &  value)
overridevirtual

Bring in the PropertyWithValue assignment operator explicitly (avoids VSC++ warning)

Parameters
value:: The value to set to
Returns
assigned PropertyWithValue

Reimplemented from Mantid::Kernel::PropertyWithValue< std::shared_ptr< IFunction > >.

Definition at line 31 of file FunctionProperty.cpp.

References value().

◆ setValue()

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

Set the value of the property.

Set the function definition.

Also tries to create the function with FunctionFactory.

Parameters
value:: The function definition string.
Returns
Error message from FunctionFactory or "" on success.

Implements Mantid::Kernel::Property.

Definition at line 73 of file FunctionProperty.cpp.

References error, isOptional(), m_definition, Mantid::Kernel::PropertyWithValue< std::shared_ptr< IFunction > >::m_value, and value().

Referenced by setValueFromJson().

◆ setValueFromJson()

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

Set the value of the property as a Json representation.

Assumes the Json object is a string and parses it to create the function.

Parameters
valueA Json::Value containing a string
Returns
An empty string indicating success otherwise the string will contain the value of the error.

Implements Mantid::Kernel::Property.

Definition at line 98 of file FunctionProperty.cpp.

References setValue(), and value().

◆ value()

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

Get the function definition string.

Get the function definition.

Returns
The function definition

Implements Mantid::Kernel::Property.

Definition at line 45 of file FunctionProperty.cpp.

References getDefault(), and Mantid::Kernel::PropertyWithValue< std::shared_ptr< IFunction > >::m_value.

Referenced by operator=(), setValue(), setValueFromJson(), and valueAsJson().

◆ valueAsJson()

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

Return a Json::Value object encoding the function string.

Returns
A Json::Value object encoding the string representation of the function

Implements Mantid::Kernel::Property.

Definition at line 56 of file FunctionProperty.cpp.

References value().

Member Data Documentation

◆ m_definition

std::string Mantid::API::FunctionProperty::m_definition
private

The function definition string (as used by the FunctionFactory)

Definition at line 83 of file FunctionProperty.h.

Referenced by setValue().

◆ m_optional

PropertyMode::Type Mantid::API::FunctionProperty::m_optional
private

A flag indicating whether the property should be considered optional.

Definition at line 81 of file FunctionProperty.h.

Referenced by isOptional().


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