Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
Mantid::Kernel::IValidator Class Referenceabstract

IValidator is the basic interface for all validators for properties. More...

#include <IValidator.h>

Inheritance diagram for Mantid::Kernel::IValidator:
Mantid::Kernel::CompositeValidator Mantid::Kernel::NullValidator

Public Member Functions

virtual std::vector< std::string > allowedValues () const
 The set of allowed values that this validator may have, if a discrete set exists. More...
 
virtual std::string check (const boost::any &) const =0
 Checks the value based on the validator's rules. More...
 
virtual IValidator_sptr clone () const =0
 Make a copy of the present type of validator. More...
 
virtual std::string getValueForAlias (const std::string &alias) const
 Implement this method for validators which wish to support aliasing for alloeed values. More...
 
virtual bool isMultipleSelectionAllowed ()
 Is Multiple Selection Allowed. More...
 
std::string isValid (const char *value) const
 Deal with a C-style string by first converting it to a std::string so that boost::any can deal with it, calls isValid(std::string) More...
 
template<typename TYPE >
std::string isValid (const TYPE &value) const
 Calls the validator. More...
 
 IValidator ()=default
 Constructor. More...
 
virtual ~IValidator ()=default
 virtual Destructor More...
 

Private Member Functions

template<typename T >
std::string runCheck (const T &value, const std::false_type &) const
 Calls the validator for a type that is not a pointer type. More...
 
template<typename T >
std::string runCheck (const T &value, const std::true_type &) const
 Calls the validator for a type that is either a raw pointer or a std::shared pointer. More...
 
template<typename T >
std::string runCheckWithDataItemPtr (const T &value, const std::false_type &) const
 Calls the validator for a pointer type that is NOT convertible to DataItem_sptr. More...
 
template<typename T >
std::string runCheckWithDataItemPtr (const T &value, const std::true_type &) const
 Calls the validator for a pointer type that IS convertible to DataItem_sptr. More...
 

Detailed Description

IValidator is the basic interface for all validators for properties.

Author
Nick Draper, Tessella Support Services plc
Date
28/11/2007

Definition at line 43 of file IValidator.h.

Constructor & Destructor Documentation

◆ IValidator()

Mantid::Kernel::IValidator::IValidator ( )
default

Constructor.

◆ ~IValidator()

virtual Mantid::Kernel::IValidator::~IValidator ( )
virtualdefault

virtual Destructor

Member Function Documentation

◆ allowedValues()

virtual std::vector< std::string > Mantid::Kernel::IValidator::allowedValues ( ) const
inlinevirtual

The set of allowed values that this validator may have, if a discrete set exists.

Overridden in applicable concrete validators; the base class just returns an empty set.

Returns
The set of allowed values that this validator may have or an empty set

Reimplemented in Mantid::Kernel::CompositeValidator.

Definition at line 77 of file IValidator.h.

◆ check()

virtual std::string Mantid::Kernel::IValidator::check ( const boost::any &  ) const
pure virtual

Checks the value based on the validator's rules.

Returns
An error message to display to users or an empty string on no error

Implemented in Mantid::Kernel::NullValidator, and Mantid::Kernel::CompositeValidator.

◆ clone()

virtual IValidator_sptr Mantid::Kernel::IValidator::clone ( ) const
pure virtual

◆ getValueForAlias()

virtual std::string Mantid::Kernel::IValidator::getValueForAlias ( const std::string &  alias) const
inlinevirtual

Implement this method for validators which wish to support aliasing for alloeed values.

Parameters
alias:: A string representation of an alias.
Returns
:: A string representation of an aliased value. Should throw std::invalid_argument is the given alias is invalid.

Definition at line 92 of file IValidator.h.

References UNUSED_ARG.

◆ isMultipleSelectionAllowed()

virtual bool Mantid::Kernel::IValidator::isMultipleSelectionAllowed ( )
inlinevirtual

Is Multiple Selection Allowed.

Returns
true if multiple selection is allowed

Definition at line 82 of file IValidator.h.

◆ isValid() [1/2]

std::string Mantid::Kernel::IValidator::isValid ( const char *  value) const
inline

Deal with a C-style string by first converting it to a std::string so that boost::any can deal with it, calls isValid(std::string)

Parameters
value:: The value to be checked
Returns
An error message to display to users or an empty string on no error

Definition at line 67 of file IValidator.h.

References isValid(), and value.

Referenced by isValid().

◆ isValid() [2/2]

template<typename TYPE >
std::string Mantid::Kernel::IValidator::isValid ( const TYPE value) const
inline

Calls the validator.

Parameters
value:: The value to be checked
Returns
An error message to display to users or an empty string on no error

Definition at line 58 of file IValidator.h.

References value.

◆ runCheck() [1/2]

template<typename T >
std::string Mantid::Kernel::IValidator::runCheck ( const T &  value,
const std::false_type &   
) const
inlineprivate

Calls the validator for a type that is not a pointer type.

Parameters
value:: The value to be checked
Returns
An error message to display to users or an empty string on no error

Definition at line 113 of file IValidator.h.

References value.

◆ runCheck() [2/2]

template<typename T >
std::string Mantid::Kernel::IValidator::runCheck ( const T &  value,
const std::true_type &   
) const
inlineprivate

Calls the validator for a type that is either a raw pointer or a std::shared pointer.

Returns
An error message to display to users or an empty string on no error

Definition at line 123 of file IValidator.h.

References value.

◆ runCheckWithDataItemPtr() [1/2]

template<typename T >
std::string Mantid::Kernel::IValidator::runCheckWithDataItemPtr ( const T &  value,
const std::false_type &   
) const
inlineprivate

Calls the validator for a pointer type that is NOT convertible to DataItem_sptr.

Parameters
value:: The value to be checked
Returns
An error message to display to users or an empty string on no error

Definition at line 134 of file IValidator.h.

References value.

◆ runCheckWithDataItemPtr() [2/2]

template<typename T >
std::string Mantid::Kernel::IValidator::runCheckWithDataItemPtr ( const T &  value,
const std::true_type &   
) const
inlineprivate

Calls the validator for a pointer type that IS convertible to DataItem_sptr.

Parameters
value:: The value to be checked
Returns
An error message to display to users or an empty string on no error

Definition at line 143 of file IValidator.h.

References value.


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