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

Attribute is a non-fitting parameter. More...

#include <IFunction.h>

Public Member Functions

template<typename... Ts>
void apply (AttributeLambdaVisitor< Ts... > &v)
 Apply a lambda visitor. More...
 
template<typename T >
apply (AttributeVisitor< T > &v)
 Apply an attribute visitor. More...
 
template<typename T >
apply (ConstAttributeVisitor< T > &v) const
 Apply a const attribute visitor. More...
 
bool asBool () const
 Returns bool value if attribute is a bool, throws exception otherwise. More...
 
double asDouble () const
 Returns double value if attribute is a double, throws exception otherwise. More...
 
int asInt () const
 Returns int value if attribute is a int, throws exception otherwise. More...
 
std::string asQuotedString () const
 Returns a string value that is guarenteed to be quoted for use in places where the string is used as the displayed value. More...
 
std::string asString () const
 Returns string value if attribute is a string, throws exception otherwise. More...
 
std::string asUnquotedString () const
 Returns a string value that is guarenteed to be unquoted. More...
 
std::vector< double > asVector () const
 Returns vector<double> if attribute is vector<double>, throws exception otherwise. More...
 
 Attribute ()
 Create empty string attribute. More...
 
 Attribute (const bool &b)
 Create bool attribute. More...
 
 Attribute (const char *c)
 Create string attribute. More...
 
 Attribute (const double &d)
 Create double attribute. More...
 
 Attribute (const int &i)
 Create int attribute. More...
 
 Attribute (const std::string &str, bool quoteValue=false)
 Create string attribute. More...
 
 Attribute (const std::vector< double > &v)
 Create vector attribute. More...
 
void evaluateValidator () const
 Evaluates the validator associated with this attribute. Returns error as a string. More...
 
template<typename T >
void evaluateValidator (T &inputData) const
 Evaluates the validator associated with this attribute with regards to input value. Returns error as a string. More...
 
void fromString (const std::string &str)
 Set value from a string. More...
 
Kernel::IValidator_sptr getValidator ()
 Return a clone of the attribute validator;. More...
 
bool isEmpty () const
 Check if a string attribute is empty. More...
 
void setBool (const bool &)
 Sets new value if attribute is a bool. More...
 
void setDouble (const double &)
 Sets new value if attribute is a double. More...
 
void setInt (const int &)
 Sets new value if attribute is a int. More...
 
void setString (const std::string &str)
 Sets new value if attribute is a string. More...
 
void setValidator (const Kernel::IValidator_sptr &validator) const
 Set validator to enforce limits on attribute value. More...
 
template<typename T >
void setValue (const T &v)
 
void setVector (const std::vector< double > &)
 Sets new value if attribute is a vector. More...
 
std::string type () const
 Returns type of the attribute. More...
 
std::string value () const
 Returns the attribute value as a string. More...
 

Private Attributes

boost::variant< std::string, int, double, bool, std::vector< double > > m_data
 The data holder as boost variant. More...
 
bool m_quoteValue = false
 Flag indicating if the string value should be returned quoted. More...
 
Kernel::IValidator_sptr m_validator
 Associated Validator. More...
 

Detailed Description

Attribute is a non-fitting parameter.

It can be one of the types: std::string, int, or double Examples: file name, polinomial order

Definition at line 282 of file IFunction.h.

Constructor & Destructor Documentation

◆ Attribute() [1/7]

Mantid::API::IFunction::Attribute::Attribute ( )
inlineexplicit

Create empty string attribute.

Definition at line 285 of file IFunction.h.

◆ Attribute() [2/7]

Mantid::API::IFunction::Attribute::Attribute ( const std::string &  str,
bool  quoteValue = false 
)
inlineexplicit

Create string attribute.

Definition at line 287 of file IFunction.h.

◆ Attribute() [3/7]

Mantid::API::IFunction::Attribute::Attribute ( const int &  i)
inlineexplicit

Create int attribute.

Definition at line 289 of file IFunction.h.

◆ Attribute() [4/7]

Mantid::API::IFunction::Attribute::Attribute ( const double &  d)
inlineexplicit

Create double attribute.

Definition at line 291 of file IFunction.h.

References Mantid::Geometry::d.

◆ Attribute() [5/7]

Mantid::API::IFunction::Attribute::Attribute ( const bool &  b)
inlineexplicit

Create bool attribute.

Definition at line 293 of file IFunction.h.

◆ Attribute() [6/7]

Mantid::API::IFunction::Attribute::Attribute ( const char *  c)
inlineexplicit

Create string attribute.

Definition at line 295 of file IFunction.h.

◆ Attribute() [7/7]

Mantid::API::IFunction::Attribute::Attribute ( const std::vector< double > &  v)
inlineexplicit

Create vector attribute.

Definition at line 297 of file IFunction.h.

Member Function Documentation

◆ apply() [1/3]

template<typename... Ts>
void Mantid::API::IFunction::Attribute::apply ( AttributeLambdaVisitor< Ts... > &  v)
inline

Apply a lambda visitor.

Definition at line 304 of file IFunction.h.

References m_data.

◆ apply() [2/3]

template<typename T >
T Mantid::API::IFunction::Attribute::apply ( AttributeVisitor< T > &  v)
inline

◆ apply() [3/3]

template<typename T >
T Mantid::API::IFunction::Attribute::apply ( ConstAttributeVisitor< T > &  v) const
inline

Apply a const attribute visitor.

Definition at line 302 of file IFunction.h.

References m_data.

◆ asBool()

bool Mantid::API::IFunction::Attribute::asBool ( ) const

◆ asDouble()

double Mantid::API::IFunction::Attribute::asDouble ( ) const

Returns double value if attribute is a double, throws exception otherwise.

Return the attribute as a double if it is a double.

Definition at line 739 of file IFunction.cpp.

References m_data.

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldSpectrum::buildTargetFunction(), Mantid::CurveFitting::Functions::CrystalFieldFunction::calcExcitations(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::calcExcitations(), Mantid::CurveFitting::Functions::BSpline::derivative1D(), Mantid::CurveFitting::Functions::BSpline::function1D(), Mantid::CurveFitting::Functions::ChudleyElliotSQE::function1D(), Mantid::CurveFitting::Functions::CriticalPeakRelaxationRate::function1D(), Mantid::CurveFitting::Functions::CrystalFieldHeatCapacityBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldMagnetisationBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldMomentBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldSusceptibilityBase::function1D(), Mantid::CurveFitting::Functions::FickDiffusionSQE::function1D(), Mantid::CurveFitting::Functions::HallRossSQE::function1D(), Mantid::CurveFitting::Functions::InelasticDiffRotDiscreteCircle::function1D(), Mantid::CurveFitting::Functions::InelasticDiffSphere::function1D(), Mantid::CurveFitting::Functions::InelasticIsoRotDiff::function1D(), Mantid::CurveFitting::Functions::TeixeiraWaterSQE::function1D(), Mantid::CurveFitting::Functions::CrystalFieldPeaks::functionGeneral(), Mantid::PythonInterface::IFunctionAdapter::getAttributeValue(), Mantid::CurveFitting::Functions::ElasticDiffRotDiscreteCircle::HeightPrefactor(), Mantid::CurveFitting::Functions::ElasticDiffSphere::HeightPrefactor(), Mantid::CurveFitting::Functions::ElasticIsoRotDiff::HeightPrefactor(), Mantid::CurveFitting::Functions::BSpline::resetKnots(), Mantid::CurveFitting::Functions::Chebyshev::setAttribute(), Mantid::CurveFitting::Functions::CubicSpline::setAttribute(), Mantid::CurveFitting::Functions::DynamicKuboToyabe::setAttribute(), Mantid::CurveFitting::Functions::FullprofPolynomial::setAttribute(), MantidQt::MantidWidgets::PropertyHandler::setAttribute(), Mantid::CurveFitting::Functions::CubicSpline::setupInput(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::updateSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSpectrum(), and Mantid::CurveFitting::Functions::CrystalFieldSpectrum::updateTargetFunction().

◆ asInt()

int Mantid::API::IFunction::Attribute::asInt ( ) const

Returns int value if attribute is a int, throws exception otherwise.

Return the attribute as an int if it is a int.

Definition at line 726 of file IFunction.cpp.

References m_data.

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldSpectrum::buildTargetFunction(), Mantid::CurveFitting::Functions::BSpline::derivative1D(), Mantid::CurveFitting::Functions::CubicSpline::derivative1D(), Mantid::CurveFitting::Functions::CubicSpline::function1D(), Mantid::CurveFitting::Functions::InelasticDiffRotDiscreteCircle::function1D(), Mantid::CurveFitting::Functions::InelasticDiffSphere::function1D(), Mantid::CurveFitting::Functions::InelasticIsoRotDiff::function1D(), Mantid::FrameworkTestHelpers::MultiDomainFunctionTest_Function::function1D(), Mantid::FrameworkTestHelpers::MultiDomainFunctionTest_Function::functionDeriv1D(), Mantid::PythonInterface::IFunctionAdapter::getAttributeValue(), Mantid::CurveFitting::Functions::ElasticDiffRotDiscreteCircle::HeightPrefactor(), Mantid::CurveFitting::Functions::Chebyshev::setAttribute(), Mantid::CurveFitting::Functions::CubicSpline::setAttribute(), Mantid::CurveFitting::Functions::FullprofPolynomial::setAttribute(), Mantid::CurveFitting::Functions::Polynomial::setAttribute(), Mantid::CurveFitting::Functions::ReflectivityMulf::setAttribute(), Mantid::CurveFitting::Functions::FunctionQDepends::setAttribute(), MantidQt::MantidWidgets::PropertyHandler::setAttribute(), MantidQt::MantidWidgets::ConvolutionFunctionModel::setPrefix(), Mantid::CurveFitting::Functions::TabulatedFunction::setupData(), and Mantid::CurveFitting::Functions::CubicSpline::setXAttribute().

◆ asQuotedString()

std::string Mantid::API::IFunction::Attribute::asQuotedString ( ) const

Returns a string value that is guarenteed to be quoted for use in places where the string is used as the displayed value.

Return the attribute as a quoted string if it is a string.

Definition at line 676 of file IFunction.cpp.

References m_data.

◆ asString()

std::string Mantid::API::IFunction::Attribute::asString ( ) const

Returns string value if attribute is a string, throws exception otherwise.

Return the attribute as a string if it is a string.

Definition at line 660 of file IFunction.cpp.

References m_data.

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldSpectrum::buildTargetFunction(), Mantid::CurveFitting::Functions::CrystalFieldPeaksBase::calculateEigenSystem(), Mantid::CurveFitting::Functions::CrystalFieldMagnetisationBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldMomentBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldSusceptibilityBase::function1D(), Mantid::PythonInterface::IFunctionAdapter::getAttributeValue(), Mantid::MDAlgorithms::UserFunctionMD::setAttribute(), Mantid::CurveFitting::Functions::PawleyParameterFunction::setAttribute(), Mantid::CurveFitting::Functions::CrystalFieldControl::setAttribute(), Mantid::CurveFitting::Functions::CrystalFieldPeaksBase::setAttribute(), MantidQt::MantidWidgets::PropertyHandler::setAttribute(), Mantid::API::MultiDomainFunction::setLocalAttribute(), MantidQt::MantidWidgets::ConvolutionFunctionModel::setPrefix(), Mantid::CurveFitting::Functions::TabulatedFunction::setupData(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::updateSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSpectrum(), and Mantid::CurveFitting::Functions::CrystalFieldSpectrum::updateTargetFunction().

◆ asUnquotedString()

std::string Mantid::API::IFunction::Attribute::asUnquotedString ( ) const

◆ asVector()

std::vector< double > Mantid::API::IFunction::Attribute::asVector ( ) const

Returns vector<double> if attribute is vector<double>, throws exception otherwise.

Return the attribute as a bool if it is a vector.

Definition at line 765 of file IFunction.cpp.

References m_data.

Referenced by Mantid::CurveFitting::Functions::CrystalFieldControl::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::buildSingleSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::buildTargetFunction(), Mantid::CurveFitting::Functions::CrystalFieldSpectrum::buildTargetFunction(), Mantid::CurveFitting::Functions::CrystalFieldControl::cacheAttributes(), Mantid::CurveFitting::Functions::CrystalFieldMagnetisationBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldMomentBase::function1D(), Mantid::CurveFitting::Functions::CrystalFieldSusceptibilityBase::function1D(), Mantid::PythonInterface::IFunctionAdapter::getAttributeValue(), Mantid::CurveFitting::Functions::BSpline::resetKnots(), Mantid::CurveFitting::Functions::BSpline::setAttribute(), Mantid::CurveFitting::Functions::CrystalFieldControl::setAttribute(), Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::setAttribute(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateMultiSiteSingleSpectrum(), Mantid::CurveFitting::Functions::CrystalFieldFunction::updateSingleSiteSingleSpectrum(), and Mantid::CurveFitting::Functions::CrystalFieldSpectrum::updateTargetFunction().

◆ evaluateValidator() [1/2]

void Mantid::API::IFunction::Attribute::evaluateValidator ( ) const

Evaluates the validator associated with this attribute. Returns error as a string.

Evaluates the validator associated with this attribute.

Definition at line 984 of file IFunction.cpp.

References m_data.

Referenced by Mantid::API::IFunction::declareAttribute().

◆ evaluateValidator() [2/2]

template<typename T >
void Mantid::API::IFunction::Attribute::evaluateValidator ( T &  inputData) const
inline

Evaluates the validator associated with this attribute with regards to input value. Returns error as a string.

Definition at line 311 of file IFunction.h.

References m_validator.

◆ fromString()

void Mantid::API::IFunction::Attribute::fromString ( const std::string &  str)

Set value from a string.

Throws exception if the string has wrong format

Parameters
str:: String representation of the new value

Definition at line 971 of file IFunction.cpp.

References m_validator, and tmp.

Referenced by Mantid::API::FunctionFactoryImpl::createSimple(), and MantidQt::MantidWidgets::PropertyHandler::setAttribute().

◆ getValidator()

Kernel::IValidator_sptr Mantid::API::IFunction::Attribute::getValidator ( )
inline

◆ isEmpty()

bool Mantid::API::IFunction::Attribute::isEmpty ( ) const

Check if a string attribute is empty.

Definition at line 858 of file IFunction.cpp.

References m_data.

Referenced by Mantid::CurveFitting::Functions::CrystalFieldFunction::hasBackground().

◆ setBool()

void Mantid::API::IFunction::Attribute::setBool ( const bool &  b)

Sets new value if attribute is a bool.

Sets new value if attribute is an bool.

If the type is wrong throws an exception

Parameters
b:: The new value

Definition at line 827 of file IFunction.cpp.

References m_data.

◆ setDouble()

void Mantid::API::IFunction::Attribute::setDouble ( const double &  d)

Sets new value if attribute is a double.

If the type is wrong throws an exception

Parameters
d:: The new value

Definition at line 795 of file IFunction.cpp.

References Mantid::Geometry::d, and m_data.

◆ setInt()

void Mantid::API::IFunction::Attribute::setInt ( const int &  i)

Sets new value if attribute is a int.

Sets new value if attribute is an int.

If the type is wrong throws an exception

Parameters
i:: The new value

Definition at line 811 of file IFunction.cpp.

References m_data.

◆ setString()

void Mantid::API::IFunction::Attribute::setString ( const std::string &  str)

Sets new value if attribute is a string.

If the type is wrong throws an exception

Parameters
str:: The new value

Definition at line 779 of file IFunction.cpp.

References m_data.

Referenced by Mantid::API::IFunction::setAttributeValue().

◆ setValidator()

void Mantid::API::IFunction::Attribute::setValidator ( const Kernel::IValidator_sptr validator) const

Set validator to enforce limits on attribute value.

Parameters
validator:: shared ptr to validator object

Definition at line 979 of file IFunction.cpp.

References m_validator.

Referenced by Mantid::API::IFunction::declareAttribute().

◆ setValue()

template<typename T >
void Mantid::API::IFunction::Attribute::setValue ( const T &  v)
inline

Definition at line 354 of file IFunction.h.

References m_data.

◆ setVector()

void Mantid::API::IFunction::Attribute::setVector ( const std::vector< double > &  v)

Sets new value if attribute is a vector.

If the type is wrong throws an exception

Parameters
v:: The new value

Definition at line 844 of file IFunction.cpp.

References m_data, and value.

Referenced by Mantid::CurveFitting::Functions::CrystalFieldMultiSpectrum::setAttribute().

◆ type()

std::string Mantid::API::IFunction::Attribute::type ( ) const

Returns type of the attribute.

Definition at line 608 of file IFunction.cpp.

References apply(), and tmp.

Referenced by Mantid::PythonInterface::IFunctionAdapter::getAttributeValue(), and MantidQt::MantidWidgets::PropertyHandler::setAttribute().

◆ value()

std::string Mantid::API::IFunction::Attribute::value ( ) const

Member Data Documentation

◆ m_data

boost::variant<std::string, int, double, bool, std::vector<double> > Mantid::API::IFunction::Attribute::m_data
mutableprivate

The data holder as boost variant.

Definition at line 364 of file IFunction.h.

◆ m_quoteValue

bool Mantid::API::IFunction::Attribute::m_quoteValue = false
private

Flag indicating if the string value should be returned quoted.

Definition at line 366 of file IFunction.h.

◆ m_validator

Kernel::IValidator_sptr Mantid::API::IFunction::Attribute::m_validator
mutableprivate

Associated Validator.

Definition at line 368 of file IFunction.h.


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