Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mantid::Kernel::ListValidator< TYPE > Class Template Reference

ListValidator is a validator that requires the value of a property to be one of a defined list of possibilities. More...

#include <ListValidator.h>

Inheritance diagram for Mantid::Kernel::ListValidator< TYPE >:
Mantid::Kernel::StartsWithValidator

Public Member Functions

void addAllowedValue (const TYPE &value)
 Add value to the list of allowable values if it's not already there. More...
 
std::vector< std::string > allowedValues () const override
 Returns the set of allowed values currently defined. More...
 
IValidator_sptr clone () const override
 Clone the validator. More...
 
std::string getValueForAlias (const std::string &alias) const override
 Return an allowed value (as a string) given an alias. More...
 
bool isMultipleSelectionAllowed () override
 
 ListValidator ()
 Default constructor. Sets up an empty list of valid values. More...
 
template<typename T >
 ListValidator (const T &values, const std::map< std::string, std::string > &aliases=std::map< std::string, std::string >(), const bool allowMultiSelection=false)
 Constructor. More...
 
void setMultipleSelectionAllowed (const bool isMultiSelectionAllowed)
 

Protected Member Functions

std::string checkValidity (const TYPE &value) const override
 Checks if the string passed is in the list. More...
 
bool isAlias (const std::string &value) const
 Test if a value is an alias of an alowed value. More...
 
template<typename T >
bool isAlias (const T &value) const
 Test if a value is an alias of an alowed value. More...
 
bool isEmpty (const std::string &value) const
 Is the value considered empty. More...
 
template<typename T >
bool isEmpty (const T &value) const
 Is the value considered empty. More...
 

Protected Attributes

std::map< std::string, std::string > m_aliases
 The optional aliases for the allowed values. More...
 
std::vector< TYPEm_allowedValues
 The set of valid values. More...
 
bool m_allowMultiSelection
 if the validator should allow multiple selection More...
 

Detailed Description

template<typename TYPE>
class Mantid::Kernel::ListValidator< TYPE >

ListValidator is a validator that requires the value of a property to be one of a defined list of possibilities.

The default type is std::string

Author
Russell Taylor, Tessella Support Services plc
Date
18/06/2008

Definition at line 29 of file ListValidator.h.

Constructor & Destructor Documentation

◆ ListValidator() [1/2]

template<typename TYPE >
Mantid::Kernel::ListValidator< TYPE >::ListValidator ( )
inline

Default constructor. Sets up an empty list of valid values.

Definition at line 32 of file ListValidator.h.

◆ ListValidator() [2/2]

template<typename TYPE >
template<typename T >
Mantid::Kernel::ListValidator< TYPE >::ListValidator ( const T &  values,
const std::map< std::string, std::string > &  aliases = std::map<std::string, std::string>(),
const bool  allowMultiSelection = false 
)
inlineexplicit

Constructor.

Parameters
values:: An iterable type of the valid values
aliases:: Optional aliases for the valid values.
allowMultiSelection:: True if the list allows multi selection

Definition at line 40 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::m_aliases, and Mantid::Kernel::ListValidator< TYPE >::m_allowMultiSelection.

Member Function Documentation

◆ addAllowedValue()

template<typename TYPE >
void Mantid::Kernel::ListValidator< TYPE >::addAllowedValue ( const TYPE value)
inline

Add value to the list of allowable values if it's not already there.

Parameters
value:: A value of the templated type

Definition at line 76 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::m_allowedValues, and value.

◆ allowedValues()

template<typename TYPE >
std::vector< std::string > Mantid::Kernel::ListValidator< TYPE >::allowedValues ( ) const
inlineoverride

Returns the set of allowed values currently defined.

Returns
A set of allowed values that this validator will currently allow

The interface requires strings

Definition at line 61 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::m_allowedValues.

◆ checkValidity()

template<typename TYPE >
std::string Mantid::Kernel::ListValidator< TYPE >::checkValidity ( const TYPE value) const
inlineoverrideprotected

Checks if the string passed is in the list.

Parameters
value:: The value to test
Returns
"" if the value is on the list, or "The value is not in the list of allowed values"

Definition at line 111 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::isAlias(), Mantid::Kernel::ListValidator< TYPE >::isEmpty(), Mantid::Kernel::ListValidator< TYPE >::m_allowedValues, and value.

◆ clone()

template<typename TYPE >
IValidator_sptr Mantid::Kernel::ListValidator< TYPE >::clone ( ) const
inlineoverride

Clone the validator.

Definition at line 56 of file ListValidator.h.

◆ getValueForAlias()

template<typename TYPE >
std::string Mantid::Kernel::ListValidator< TYPE >::getValueForAlias ( const std::string &  alias) const
inlineoverride

Return an allowed value (as a string) given an alias.

Parameters
alias:: An alias string.
Returns
:: Allowed value or throw if alias is unknown.

Definition at line 88 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::m_aliases.

◆ isAlias() [1/2]

template<typename TYPE >
bool Mantid::Kernel::ListValidator< TYPE >::isAlias ( const std::string &  value) const
inlineprotected

Test if a value is an alias of an alowed value.

Parameters
value:: Value to test.
Returns
:: True if it's an alias.

Definition at line 153 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::m_aliases, and value.

◆ isAlias() [2/2]

template<typename TYPE >
template<typename T >
bool Mantid::Kernel::ListValidator< TYPE >::isAlias ( const T &  value) const
inlineprotected

Test if a value is an alias of an alowed value.

Parameters
value:: Value to test.
Returns
:: True if it's an alias.

Definition at line 143 of file ListValidator.h.

References Mantid::Kernel::ListValidator< TYPE >::m_aliases, and value.

Referenced by Mantid::Kernel::ListValidator< TYPE >::checkValidity().

◆ isEmpty() [1/2]

template<typename TYPE >
bool Mantid::Kernel::ListValidator< TYPE >::isEmpty ( const std::string &  value) const
inlineprotected

Is the value considered empty.

Specialized string version to use empty

Parameters
value:: The value to check
Returns
True if it is considered empty

Definition at line 136 of file ListValidator.h.

References value.

◆ isEmpty() [2/2]

template<typename TYPE >
template<typename T >
bool Mantid::Kernel::ListValidator< TYPE >::isEmpty ( const T &  value) const
inlineprotected

Is the value considered empty.

Parameters
value:: The value to check
Returns
True if it is considered empty

Definition at line 130 of file ListValidator.h.

References UNUSED_ARG, and value.

Referenced by Mantid::Kernel::StartsWithValidator::checkValidity(), and Mantid::Kernel::ListValidator< TYPE >::checkValidity().

◆ isMultipleSelectionAllowed()

template<typename TYPE >
bool Mantid::Kernel::ListValidator< TYPE >::isMultipleSelectionAllowed ( )
inlineoverride

◆ setMultipleSelectionAllowed()

template<typename TYPE >
void Mantid::Kernel::ListValidator< TYPE >::setMultipleSelectionAllowed ( const bool  isMultiSelectionAllowed)
inline

Member Data Documentation

◆ m_aliases

template<typename TYPE >
std::map<std::string, std::string> Mantid::Kernel::ListValidator< TYPE >::m_aliases
protected

◆ m_allowedValues

template<typename TYPE >
std::vector<TYPE> Mantid::Kernel::ListValidator< TYPE >::m_allowedValues
protected

◆ m_allowMultiSelection

template<typename TYPE >
bool Mantid::Kernel::ListValidator< TYPE >::m_allowMultiSelection
protected

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