Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Mantid::PythonInterface::PythonObjectProperty Class Reference

#include <PythonObjectProperty.h>

Inheritance diagram for Mantid::PythonInterface::PythonObjectProperty:
Mantid::Kernel::PropertyWithValue< PythonObject > Mantid::Kernel::Property

Public Types

using BaseClass = Mantid::Kernel::PropertyWithValue< ValueType >
 
using ValueType = PythonObject
 

Public Member Functions

PythonObjectPropertyclone () const override
 This is required by Property interface.
 
std::string getDefault () const override
 
bool isDefault () const override
 Indicates if the value matches the value None.
 
PropertyWithValueoperator= (const PropertyWithValue &right)
 Copy assignment operator assigns only the value and the validator not the name, default (initial) value, etc.
 
virtual PropertyWithValueoperator= (const TYPE &value)
 Assignment operator.
 
 PythonObjectProperty ()=delete
 No default constructor.
 
 PythonObjectProperty (PythonObjectProperty const &other)
 Copy constructor.
 
 PythonObjectProperty (std::string const &name, IValidator_sptr const &validator, unsigned int const direction=Direction::Input)
 Constructor Will lead to the property having default value of None.
 
 PythonObjectProperty (std::string const &name, PythonObject const &defaultValue, IValidator_sptr const &validator=std::make_shared< NullValidator >(), unsigned int const direction=Direction::Input)
 Constructor.
 
 PythonObjectProperty (std::string const &name, PythonObject const &defaultValue, unsigned int const direction=Direction::Input)
 Constructor that's useful for output properties or inputs with non-None default and no validator.
 
 PythonObjectProperty (std::string const &name, std::string const &strvalue, IValidator_sptr const &validator=std::make_shared< NullValidator >(), unsigned int const direction=Direction::Input)
 Constructor from which you can set the property's values through a string:
 
 PythonObjectProperty (std::string const &name, unsigned int const direction=Direction::Input)
 Constructor that's useful for output properties or inputs with default value None and no validator.
 
std::string setDataItem (std::shared_ptr< Kernel::DataItem > const &value) override
 Set the value of the property via a DataItem pointer.
 
std::string setValue (PythonObject const &obj)
 Set the property value.
 
std::string setValue (std::string const &value) override
 Set the property value.
 
std::string setValueFromJson (Json::Value const &value) override
 Assumes the Json object is a string and parses it to create the object.
 
- Public Member Functions inherited from Mantid::Kernel::PropertyWithValue< PythonObject >
std::vector< std::string > allowedValues () const override
 Returns the set of valid values for this property, if such a set exists.
 
PropertyWithValue< PythonObject > * 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 PythonObject & () const
 Allows you to get the value of the property simply by typing its name.
 
bool operator!= (const PropertyWithValue< PythonObject > &rhs) const
 Deep comparison (not equal).
 
virtual const PythonObjectoperator() () 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< PythonObject > &rhs) const
 Deep comparison.
 
 PropertyWithValue ()=delete
 
 PropertyWithValue (const PropertyWithValue< PythonObject > &right)
 Copy constructor Note the default value of the copied object is the initial value of original.
 
 PropertyWithValue (const std::string &name, const PythonObject &defaultValue, const std::string &defaultValueStr, IValidator_sptr validator, const unsigned int direction)
 Constructor.
 
 PropertyWithValue (std::string name, PythonObject defaultValue, const unsigned int direction)
 Constructor.
 
 PropertyWithValue (std::string name, PythonObject 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.
 

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

Detailed Description

Definition at line 48 of file PythonObjectProperty.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 52 of file PythonObjectProperty.h.

◆ ValueType

Definition at line 51 of file PythonObjectProperty.h.

Constructor & Destructor Documentation

◆ PythonObjectProperty() [1/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( )
delete

No default constructor.

◆ PythonObjectProperty() [2/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( std::string const &  name,
PythonObject const &  defaultValue,
IValidator_sptr const &  validator = std::make_shared<NullValidator>(),
unsigned int const  direction = Direction::Input 
)
inline

Constructor.

Parameters
name:: The name to assign to the property
defaultValue:: The default python object to assign to the property
validator:: The validator to use for this property, if required.
direction:: The direction (Input/Output/InOut) of this property

Definition at line 63 of file PythonObjectProperty.h.

◆ PythonObjectProperty() [3/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( std::string const &  name,
PythonObject const &  defaultValue,
unsigned int const  direction = Direction::Input 
)
inline

Constructor that's useful for output properties or inputs with non-None default and no validator.

Parameters
name:: The name to assign to the property
defaultValue:: The default python object to assign to the property
direction:: The direction (Input/Output/InOut) of this property

Definition at line 73 of file PythonObjectProperty.h.

◆ PythonObjectProperty() [4/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( std::string const &  name,
IValidator_sptr const &  validator,
unsigned int const  direction = Direction::Input 
)
inline

Constructor Will lead to the property having default value of None.

Parameters
name:: The name to assign to the property
validator:: The validator to use for this property, if required
direction:: The direction (Input/Output/InOut) of this property

Definition at line 83 of file PythonObjectProperty.h.

◆ PythonObjectProperty() [5/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( std::string const &  name,
unsigned int const  direction = Direction::Input 
)
inline

Constructor that's useful for output properties or inputs with default value None and no validator.

Will lead to the property having a default initial value of None and no validator

Parameters
name:: The name to assign to the property
direction:: The direction (Input/Output/InOut) of this property

Definition at line 92 of file PythonObjectProperty.h.

◆ PythonObjectProperty() [6/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( std::string const &  name,
std::string const &  strvalue,
IValidator_sptr const &  validator = std::make_shared<NullValidator>(),
unsigned int const  direction = Direction::Input 
)
inline

Constructor from which you can set the property's values through a string:

Parameters
name:: The name to assign to the property
strvalue:: A string which will set the property being stored
validator:: The validator to use for this property, if required
direction:: The direction (Input/Output/InOut) of this property
Exceptions
std::invalid_argumentif the string passed is not compatible with a python object

Definition at line 102 of file PythonObjectProperty.h.

◆ PythonObjectProperty() [7/7]

Mantid::PythonInterface::PythonObjectProperty::PythonObjectProperty ( PythonObjectProperty const &  other)
inline

Copy constructor.

Definition at line 108 of file PythonObjectProperty.h.

Member Function Documentation

◆ clone()

PythonObjectProperty * Mantid::PythonInterface::PythonObjectProperty::clone ( ) const
inlineoverridevirtual

This is required by Property interface.

Implements Mantid::Kernel::Property.

Definition at line 111 of file PythonObjectProperty.h.

◆ getDefault()

std::string Mantid::PythonInterface::PythonObjectProperty::getDefault ( ) const
overridevirtual
Returns
A string representati on of the default value

Implements Mantid::Kernel::Property.

Definition at line 158 of file PythonObjectProperty.cpp.

References Mantid::Kernel::toString().

◆ isDefault()

bool Mantid::PythonInterface::PythonObjectProperty::isDefault ( ) const
overridevirtual

Indicates if the value matches the value None.

Returns
true if the value is None NOTE: For reasons (surely good ones), trying to compare m_value to m_initialValue raises a segfault

Implements Mantid::Kernel::Property.

Definition at line 227 of file PythonObjectProperty.cpp.

References m_value.

◆ operator=() [1/2]

Copy assignment operator assigns only the value and the validator not the name, default (initial) value, etc.

Definition at line 54 of file PropertyWithValue.hxx.

◆ operator=() [2/2]

PropertyWithValue< TYPE > & Mantid::Kernel::PropertyWithValue< TYPE >::operator= ( const TYPE value)
virtual

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

Reimplemented from Mantid::Kernel::PropertyWithValue< PythonObject >.

Definition at line 56 of file PropertyWithValue.hxx.

◆ setDataItem()

std::string Mantid::PythonInterface::PythonObjectProperty::setDataItem ( std::shared_ptr< Kernel::DataItem > const &  )
overridevirtual

Set the value of the property via a DataItem pointer.

If the value is unacceptable the value is not changed but a string is returned

Implements Mantid::Kernel::Property.

Definition at line 219 of file PythonObjectProperty.cpp.

◆ setValue() [1/2]

std::string Mantid::PythonInterface::PythonObjectProperty::setValue ( PythonObject const &  value)

Set the property value.

Parameters
value:: The object definition string.
Returns
Error message, or "" on success.

Definition at line 164 of file PythonObjectProperty.cpp.

References value.

Referenced by export_PythonObjectProperty().

◆ setValue() [2/2]

std::string Mantid::PythonInterface::PythonObjectProperty::setValue ( std::string const &  value)
overridevirtual

Set the property value.

Parameters
value:: The value of the property as a string.
Returns
Error message, or "" on success.

Implements Mantid::Kernel::Property.

Definition at line 178 of file PythonObjectProperty.cpp.

References value.

◆ setValueFromJson()

std::string Mantid::PythonInterface::PythonObjectProperty::setValueFromJson ( Json::Value const &  value)
overridevirtual

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

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 214 of file PythonObjectProperty.cpp.


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