Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Types | Private Member Functions | List of all members
Mantid::Kernel::EnumeratedStringProperty< E, names > Class Template Reference

A concrete property based on user options of a finite list of strings. More...

#include <EnumeratedStringProperty.h>

Inheritance diagram for Mantid::Kernel::EnumeratedStringProperty< E, names >:
Mantid::Kernel::Property

Public Member Functions

std::vector< std::string > allowedValues () const override
 Returns the set of valid values for this property, if such a set exists.
 
EnumeratedStringPropertyclone () const override
 Virtual copy constructor.
 
 EnumeratedStringProperty (EnumeratedStringProperty const &right)
 Copy Constructor.
 
 EnumeratedStringProperty (std::string const &name, ENUMSTRING const &defaultValue=static_cast< E >(0), Direction::Type const direction=Direction::Input)
 Constructor.
 
std::string getDefault () const override
 Get the value the property was initialised with -its default value.
 
bool isDefault () const override
 Indicates if the property's value is the same as it was when it was set N.B.
 
std::string isValid () const override
 If the value has been set, then it is valid.
 
 operator E () const
 
 operator ENUMSTRING () const
 Allows you to get the value of the property simply by typing its name.
 
 operator std::string () const
 
bool operator!= (EnumeratedStringProperty const &rhs) const
 Deep comparison (not equal).
 
ENUMSTRING operator() () const
 Allows you to get the value of the property simply by typing its name.
 
EnumeratedStringPropertyoperator+= (Property const *right) override
 Add the value of another property.
 
EnumeratedStringProperty const & operator= (E const value)
 Assignment operator.
 
EnumeratedStringPropertyoperator= (EnumeratedStringProperty const &right)
 Assignment operator.
 
EnumeratedStringProperty const & operator= (ENUMSTRING const &value)
 Assignment operator.
 
EnumeratedStringProperty const & operator= (std::string const &value)
 Assignment operator.
 
bool operator== (EnumeratedStringProperty const &rhs) const
 Deep comparison.
 
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 (E const value)
 Set the value of the property from a string representation.
 
std::string setValue (ENUMSTRING const &value)
 Set the value of the property from a string representation.
 
std::string setValue (std::string const &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 (size_t const maxLength=0, bool const collapseLists=true) const override
 Get the value of the property as a more prettier 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 isMultipleSelectionAllowed ()
 Is Multiple Selection Allowed.
 
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.
 

Protected Attributes

ENUMSTRING m_initialValue
 the property's default value which is also its initial value
 
ENUMSTRING m_value
 The value of the property.
 
- Protected Attributes inherited from Mantid::Kernel::Property
std::string m_name
 The name of the property.
 

Private Types

using ENUMSTRING = EnumeratedString< E, names >
 

Private Member Functions

template<typename U >
std::string setTypedValue (U const &value, std::false_type const &)
 Helper function for setValue(DataItem_sptr).
 
template<typename U >
std::string setTypedValue (U const &value, std::true_type const &)
 Helper function for setValue(DataItem_sptr).
 
std::string setValueFromProperty (Property const &right) override
 Set the value of the property via a reference to another property.
 

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.
 

Detailed Description

template<class E, std::vector< std::string > const *const names>
class Mantid::Kernel::EnumeratedStringProperty< E, names >

A concrete property based on user options of a finite list of strings.

Allows for easy comparison by binding the string list to an enum.

Author
Reece Boston, ORNL
Date
October 1, in this the two-thousand-and-twenty-fourth year of our Lord

Definition at line 23 of file EnumeratedStringProperty.h.

Member Typedef Documentation

◆ ENUMSTRING

template<class E , std::vector< std::string > const *const names>
using Mantid::Kernel::EnumeratedStringProperty< E, names >::ENUMSTRING = EnumeratedString<E, names>
private

Definition at line 25 of file EnumeratedStringProperty.h.

Constructor & Destructor Documentation

◆ EnumeratedStringProperty() [1/2]

template<class E , std::vector< std::string > const *const names>
Mantid::Kernel::EnumeratedStringProperty< E, names >::EnumeratedStringProperty ( std::string const &  name,
ENUMSTRING const &  defaultValue = static_cast<E>(0),
Direction::Type const  direction = Direction::Input 
)

Constructor.

Parameters
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 30 of file EnumeratedStringProperty.hxx.

◆ EnumeratedStringProperty() [2/2]

template<class E , std::vector< std::string > const *const names>
Mantid::Kernel::EnumeratedStringProperty< E, names >::EnumeratedStringProperty ( EnumeratedStringProperty< E, names > const &  right)

Copy Constructor.

Parameters
right:: a copy

Definition at line 38 of file EnumeratedStringProperty.hxx.

Member Function Documentation

◆ allowedValues()

template<class E , std::vector< std::string > const *const names>
std::vector< std::string > Mantid::Kernel::EnumeratedStringProperty< E, names >::allowedValues ( ) const
overridevirtual

Returns the set of valid values for this property, if such a set exists.

If not, it returns an empty vector.

Returns
Returns the set of valid values for this property, or it returns an empty vector.

Reimplemented from Mantid::Kernel::Property.

Definition at line 169 of file EnumeratedStringProperty.hxx.

◆ clone()

template<class E , std::vector< std::string > const *const names>
EnumeratedStringProperty< E, names > * Mantid::Kernel::EnumeratedStringProperty< E, names >::clone ( ) const
overridevirtual

Virtual copy constructor.

Implements Mantid::Kernel::Property.

Definition at line 45 of file EnumeratedStringProperty.hxx.

◆ getDefault()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::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 128 of file EnumeratedStringProperty.hxx.

◆ isDefault()

template<class E , std::vector< std::string > const *const names>
bool Mantid::Kernel::EnumeratedStringProperty< E, names >::isDefault ( ) const
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

Returns
true if the value is the same as the initial value or false otherwise

Implements Mantid::Kernel::Property.

Definition at line 159 of file EnumeratedStringProperty.hxx.

References m_value.

◆ isValid()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::isValid ( ) const
overridevirtual

If the value has been set, then it is valid.

Returns
"" if the value is valid or a discription of the problem

Reimplemented from Mantid::Kernel::Property.

Definition at line 145 of file EnumeratedStringProperty.hxx.

References m_value.

◆ operator E()

template<class E , std::vector< std::string > const *const names>
Mantid::Kernel::EnumeratedStringProperty< E, names >::operator E ( ) const
inline

◆ operator ENUMSTRING()

template<class E , std::vector< std::string > const *const names>
Mantid::Kernel::EnumeratedStringProperty< E, names >::operator ENUMSTRING ( ) const
inline

Allows you to get the value of the property simply by typing its name.

Means you can use an expression like: int i = myProperty;

Returns
the value

Definition at line 49 of file EnumeratedStringProperty.h.

References Mantid::Kernel::EnumeratedStringProperty< E, names >::m_value.

◆ operator std::string()

template<class E , std::vector< std::string > const *const names>
Mantid::Kernel::EnumeratedStringProperty< E, names >::operator std::string ( ) const
inline

◆ operator!=()

template<class E , std::vector< std::string > const *const names>
bool Mantid::Kernel::EnumeratedStringProperty< E, names >::operator!= ( EnumeratedStringProperty< E, names > const &  rhs) const

Deep comparison (not equal).

Parameters
rhsThe other property to compare to.
Returns
true if they are not equal.

Definition at line 114 of file EnumeratedStringProperty.hxx.

References rhs.

◆ operator()()

template<class E , std::vector< std::string > const *const names>
EnumeratedString< E, names > Mantid::Kernel::EnumeratedStringProperty< E, names >::operator() ( ) const

Allows you to get the value of the property simply by typing its name.

Means you can use an expression like: int i = myProperty();

Returns
the value

Definition at line 137 of file EnumeratedStringProperty.hxx.

References m_value.

◆ operator+=()

template<class E , std::vector< std::string > const *const names>
EnumeratedStringProperty< E, names > & Mantid::Kernel::EnumeratedStringProperty< E, names >::operator+= ( Property const *  right)
overridevirtual

Add the value of another property.

Parameters
rightthe property to add
Returns
the sum

Implements Mantid::Kernel::Property.

Definition at line 302 of file EnumeratedStringProperty.hxx.

References right.

◆ operator=() [1/4]

template<class E , std::vector< std::string > const *const names>
EnumeratedStringProperty< E, names > const & Mantid::Kernel::EnumeratedStringProperty< E, names >::operator= ( E const  value)

Assignment operator.

Allows assignment of a new value to the property by writing, e.g., myProperty = 3;

Parameters
value:: The new value to assign to the property
Returns
the reference to itself

Definition at line 260 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ operator=() [2/4]

template<class E , std::vector< std::string > const *const names>
EnumeratedStringProperty< E, names > & Mantid::Kernel::EnumeratedStringProperty< E, names >::operator= ( EnumeratedStringProperty< E, names > const &  right)

Assignment operator.

Copy assignment operator assigns only the value and the validator not the name, default (initial) value, etc. Allows assignment of a new value to the property by writing, e.g., myProperty = 3;

Parameters
right:: The new value to assign to the property
Returns
the reference to itself

Definition at line 59 of file EnumeratedStringProperty.hxx.

References m_value, Mantid::Kernel::EnumeratedStringProperty< E, names >::m_value, and right.

◆ operator=() [3/4]

template<class E , std::vector< std::string > const *const names>
EnumeratedStringProperty< E, names > const & Mantid::Kernel::EnumeratedStringProperty< E, names >::operator= ( ENUMSTRING const &  value)

Assignment operator.

Allows assignment of a new value to the property by writing, e.g., myProperty = 3;

Parameters
value:: The new value to assign to the property
Returns
the reference to itself

Definition at line 287 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ operator=() [4/4]

template<class E , std::vector< std::string > const *const names>
EnumeratedStringProperty< E, names > const & Mantid::Kernel::EnumeratedStringProperty< E, names >::operator= ( std::string const &  value)

Assignment operator.

Allows assignment of a new value to the property by writing, e.g., myProperty = 3;

Parameters
value:: The new value to assign to the property
Returns
the reference to itself

Definition at line 273 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ operator==()

template<class E , std::vector< std::string > const *const names>
bool Mantid::Kernel::EnumeratedStringProperty< E, names >::operator== ( EnumeratedStringProperty< E, names > const &  rhs) const

Deep comparison.

Parameters
rhsThe other property to compare to.
Returns
true if the are equal.

Definition at line 102 of file EnumeratedStringProperty.hxx.

References m_value, name, Mantid::Kernel::Property::name(), and rhs.

◆ saveProperty()

template<class E , std::vector< std::string > const *const names>
void Mantid::Kernel::EnumeratedStringProperty< E, names >::saveProperty ( Nexus::File *  file)
overridevirtual

Reimplemented from Mantid::Kernel::Property.

Definition at line 310 of file EnumeratedStringProperty.hxx.

References name.

◆ setDataItem()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setDataItem ( const std::shared_ptr< DataItem > &  data)
overridevirtual

Set a property value via a DataItem.

Parameters
data:: A shared pointer to a data item
Returns
"" if the assignment was successful or a user level description of the problem

Implements Mantid::Kernel::Property.

Definition at line 245 of file EnumeratedStringProperty.hxx.

◆ setTypedValue() [1/2]

template<class E , std::vector< std::string > const *const names>
template<typename U >
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setTypedValue ( U const &  value,
std::false_type const &   
)
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>

Parameters
value:: A object of type convertible to std::shared_ptr<DataItem>

Definition at line 368 of file EnumeratedStringProperty.hxx.

References name.

◆ setTypedValue() [2/2]

template<class E , std::vector< std::string > const *const names>
template<typename U >
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setTypedValue ( U const &  value,
std::true_type const &   
)
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>

Parameters
value:: A object of type convertible to std::shared_ptr<DataItem>

Definition at line 349 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ setValue() [1/3]

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setValue ( E const  value)

Set the value of the property from a string representation.

Parameters
value:: The value to assign to the property
Returns
Returns "" if the assignment was successful or a user level description of the problem

Definition at line 183 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ setValue() [2/3]

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setValue ( ENUMSTRING const &  value)

Set the value of the property from a string representation.

Parameters
value:: The value to assign to the property
Returns
Returns "" if the assignment was successful or a user level description of the problem

Definition at line 213 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ setValue() [3/3]

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setValue ( std::string const &  value)
overridevirtual

Set the value of the property from a string representation.

Parameters
value:: The value to assign to the property
Returns
Returns "" if the assignment was successful or a user level description of the problem

Implements Mantid::Kernel::Property.

Definition at line 194 of file EnumeratedStringProperty.hxx.

References m_value, and value.

◆ setValueFromJson()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setValueFromJson ( const Json::Value &  value)
overridevirtual

Set the value of the property from a Json representation.

Parameters
value:: The value to assign to the property
Returns
Returns "" if the assignment was successful or a user level description of the problem

Implements Mantid::Kernel::Property.

Definition at line 225 of file EnumeratedStringProperty.hxx.

References value.

◆ setValueFromProperty()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::setValueFromProperty ( Property const &  right)
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

Parameters
right:: A reference to a property.

Implements Mantid::Kernel::Property.

Definition at line 330 of file EnumeratedStringProperty.hxx.

References m_value, and right.

◆ size()

template<class E , std::vector< std::string > const *const names>
int Mantid::Kernel::EnumeratedStringProperty< E, names >::size ( ) const
overridevirtual

Get the size of the property.

Reimplemented from Mantid::Kernel::Property.

Definition at line 120 of file EnumeratedStringProperty.hxx.

◆ value()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::value ( ) const
overridevirtual

Get the value of the property as a string.

Returns
The property's value as a string

Implements Mantid::Kernel::Property.

Definition at line 74 of file EnumeratedStringProperty.hxx.

References m_value.

◆ valueAsJson()

template<class E , std::vector< std::string > const *const names>
Json::Value Mantid::Kernel::EnumeratedStringProperty< E, names >::valueAsJson ( ) const
overridevirtual

Attempt to construct a Json::Value object from the plain value.

Returns
A new Json::Value object

Implements Mantid::Kernel::Property.

Definition at line 92 of file EnumeratedStringProperty.hxx.

References Mantid::Kernel::encodeAsJson().

◆ valueAsPrettyStr()

template<class E , std::vector< std::string > const *const names>
std::string Mantid::Kernel::EnumeratedStringProperty< E, names >::valueAsPrettyStr ( size_t const  maxLength = 0,
bool const  collapseLists = true 
) const
overridevirtual

Get the value of the property as a more prettier string.

Returns
The property's value as a more prettier string

Reimplemented from Mantid::Kernel::Property.

Definition at line 82 of file EnumeratedStringProperty.hxx.

References m_value, and Mantid::Kernel::toPrettyString().

Member Data Documentation

◆ m_initialValue

template<class E , std::vector< std::string > const *const names>
ENUMSTRING Mantid::Kernel::EnumeratedStringProperty< E, names >::m_initialValue
protected

the property's default value which is also its initial value

Definition at line 76 of file EnumeratedStringProperty.h.

◆ m_value

template<class E , std::vector< std::string > const *const names>
ENUMSTRING Mantid::Kernel::EnumeratedStringProperty< E, names >::m_value
protected

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