Mantid
|
#include <CompositeValidator.h>
Public Member Functions | |
template<typename T > | |
void | add () |
Add a validator based on a template type. More... | |
void | add (const IValidator_sptr &child) |
Adds a validator to the group of validators to check. More... | |
template<typename T , typename U > | |
void | add (const U &arg) |
Add a validator based on the first template type with the second as an argument. More... | |
std::vector< std::string > | allowedValues () const override |
Return the instersection of allowed values from children. More... | |
IValidator_sptr | clone () const override |
Clones this and the children into a new Validator. More... | |
CompositeValidator (const CompositeRelation &relation=CompositeRelation::AND) | |
Default constructor. More... | |
template<typename T > | |
bool | contains () |
Returns true if the child list contains a validator of the specified template type. More... | |
std::string | getType () const |
Gets the type of the validator. More... | |
~CompositeValidator () override | |
Destructor. More... | |
Public Member Functions inherited from Mantid::Kernel::IValidator | |
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 | |
std::string | buildErrorMessage (const bool valid, const std::string &errors) const |
build an error message for OR relations More... | |
std::string | check (const boost::any &value) const override |
Verify the value with the child validators. More... | |
std::string | checkAll (const boost::any &value) const |
Verify the value with the child validators with logical "and" relationship. More... | |
std::string | checkAny (const boost::any &value) const |
Verify the value with the child validators with logical "or" relationship. More... | |
CompositeValidator (const CompositeValidator &) | |
Private Copy constructor: NO DIRECT COPY ALLOWED. More... | |
Private Attributes | |
std::list< IValidator_sptr > | m_children |
A container for the child validators. More... | |
const CompositeRelation | m_relation |
Store what relationship child validators have. More... | |
Definition at line 30 of file CompositeValidator.h.
Mantid::Kernel::CompositeValidator::CompositeValidator | ( | const CompositeRelation & | relation = CompositeRelation::AND | ) |
Default constructor.
Definition at line 16 of file CompositeValidator.cpp.
|
override |
|
private |
Private Copy constructor: NO DIRECT COPY ALLOWED.
|
inline |
Add a validator based on a template type.
Useful for validators that need no arguments
Definition at line 47 of file CompositeValidator.h.
References add().
Referenced by add(), and export_CompositeValidator().
void Mantid::Kernel::CompositeValidator::add | ( | const IValidator_sptr & | child | ) |
Adds a validator to the group of validators to check.
child | :: A pointer to the validator to add |
Definition at line 70 of file CompositeValidator.cpp.
References m_children.
|
inline |
Add a validator based on the first template type with the second as an argument.
The argument is used to feed into the validator constructor
Definition at line 51 of file CompositeValidator.h.
References add().
Referenced by add().
|
overridevirtual |
Return the instersection of allowed values from children.
The allowed values for the composite validator.
This returns the intersection of the allowedValues for the child validators
Reimplemented from Mantid::Kernel::IValidator.
Definition at line 27 of file CompositeValidator.cpp.
References m_children.
|
private |
build an error message for OR relations
Return a user friendly error message.
Returns empty string if no errors were found.
valid | :: whether all the validator succeded |
errors | :: the combined list of errors from the child validators |
Definition at line 129 of file CompositeValidator.cpp.
Referenced by checkAny().
|
overrideprivatevirtual |
Verify the value with the child validators.
Checks the value of all child validators.
Fails if any child fails.
value | :: The workspace to test |
Implements Mantid::Kernel::IValidator.
Definition at line 76 of file CompositeValidator.cpp.
References Mantid::Kernel::AND, checkAll(), checkAny(), m_relation, Mantid::Kernel::OR, and value.
|
private |
Verify the value with the child validators with logical "and" relationship.
Definition at line 87 of file CompositeValidator.cpp.
References error, m_children, and value.
Referenced by check().
|
private |
Verify the value with the child validators with logical "or" relationship.
Definition at line 99 of file CompositeValidator.cpp.
References buildErrorMessage(), m_children, and value.
Referenced by check().
|
overridevirtual |
Clones this and the children into a new Validator.
Clone the validator.
Implements Mantid::Kernel::IValidator.
Definition at line 59 of file CompositeValidator.cpp.
References m_children, and m_relation.
|
inline |
Returns true if the child list contains a validator of the specified template type.
Definition at line 54 of file CompositeValidator.h.
|
inline |
Gets the type of the validator.
Definition at line 38 of file CompositeValidator.h.
|
private |
A container for the child validators.
Definition at line 74 of file CompositeValidator.h.
Referenced by add(), allowedValues(), checkAll(), checkAny(), clone(), and ~CompositeValidator().
|
private |
Store what relationship child validators have.
Definition at line 76 of file CompositeValidator.h.