Skip to content

Commit

Permalink
Refs #4399. IValidator::clone should be const.
Browse files Browse the repository at this point in the history
A clone should be a guaranteed copy of the current state of
the object.
  • Loading branch information
martyngigg committed Mar 1, 2012
1 parent ec4dd34 commit 5c04f6d
Show file tree
Hide file tree
Showing 23 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace Mantid
*/
inline std::string getType() const { return "AlgorithmHasProperty"; }
/// Make a copy of the present type of validator
inline Kernel::IValidator<boost::shared_ptr<IAlgorithm> >* clone()
inline Kernel::IValidator<boost::shared_ptr<IAlgorithm> >* clone() const
{
return new AlgorithmHasProperty(*this);
}
Expand Down
14 changes: 7 additions & 7 deletions Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceValidators.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DLLExport WorkspaceUnitValidator : public Kernel::IValidator<boost::shared
///Gets the type of the validator
std::string getType() const { return "workspaceunit"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new WorkspaceUnitValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new WorkspaceUnitValidator(*this); }

private:
/** Checks that the units of the workspace data are declared match any required units
Expand Down Expand Up @@ -131,7 +131,7 @@ class DLLExport HistogramValidator : public Kernel::IValidator<boost::shared_ptr
///Gets the type of the validator
std::string getType() const { return "histogram"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new HistogramValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new HistogramValidator(*this); }

private:
/** Checks if the workspace contains a histogram when it shouldn't and vice-versa
Expand Down Expand Up @@ -179,7 +179,7 @@ class DLLExport RawCountValidator : public Kernel::IValidator<boost::shared_ptr<
///Gets the type of the validator
std::string getType() const { return "rawcount"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new RawCountValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new RawCountValidator(*this); }

private:
/** Checks if the workspace must be a distribution but isn't and vice-versa
Expand Down Expand Up @@ -224,7 +224,7 @@ class DLLExport CommonBinsValidator : public Kernel::IValidator<boost::shared_pt
///Gets the type of the validator
std::string getType() const { return "commonbins"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new CommonBinsValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new CommonBinsValidator(*this); }

private:
/** Checks that the bin boundaries of each histogram in the workspace are the same
Expand Down Expand Up @@ -269,7 +269,7 @@ class DLLExport SpectraAxisValidator : public Kernel::IValidator<boost::shared_p
///Gets the type of the validator
std::string getType() const { return "spectraaxis"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new SpectraAxisValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new SpectraAxisValidator(*this); }

private:
/** Checks that the axis stated
Expand Down Expand Up @@ -303,7 +303,7 @@ class DLLExport NumericAxisValidator : public Kernel::IValidator<boost::shared_p
///Gets the type of the validator
std::string getType() const { return "numericaaxis"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new NumericAxisValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new NumericAxisValidator(*this); }

private:
/** Checks that the axis stated
Expand Down Expand Up @@ -340,7 +340,7 @@ class DLLExport InstrumentValidator : public Kernel::IValidator<boost::shared_pt
///Gets the type of the validator
std::string getType() const { return "Instrument"; }

Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() { return new InstrumentValidator(*this); }
Kernel::IValidator<boost::shared_ptr<TYPE> >* clone() const { return new InstrumentValidator(*this); }

private:
/** Checks that the workspace has an instrument defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MANTID_KERNEL_DLL ArrayBoundedValidator: public IValidator<std::vector<TYP
ArrayBoundedValidator(BoundedValidator<TYPE> &bv);
virtual ~ArrayBoundedValidator();

IValidator<std::vector<TYPE> >* clone();
IValidator<std::vector<TYPE> >* clone() const;
BoundedValidator<TYPE>* getValidator() const;
std::string isValid(const std::vector<TYPE> &value) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Kernel
ArrayLengthValidator(const size_t lenmin, const size_t lenmax);
virtual ~ArrayLengthValidator();

IValidator<std::vector<TYPE> >* clone();
IValidator<std::vector<TYPE> >* clone() const;

std::string isValid(const std::vector<TYPE> &value) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class DLLExport BoundedValidator : public IValidator<TYPE>
clearUpper();
}

IValidator<TYPE>* clone() { return new BoundedValidator(*this); }
IValidator<TYPE>* clone() const { return new BoundedValidator(*this); }

private:
// Data and Function Members for This Class Implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace Kernel

}
// ------------------------------------------------------------------------------------
Kernel::IValidator<TYPE>* clone()
Kernel::IValidator<TYPE>* clone() const
{
CompositeValidator<TYPE>* copy = new CompositeValidator<TYPE>();
for (unsigned int i=0; i < m_children.size(); ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MANTID_KERNEL_DLL DateValidator : public IValidator<std::string>
public:
DateValidator();
virtual ~DateValidator();
IValidator<std::string> * clone();
IValidator<std::string> * clone() const;

private:
struct tm getTimevalue(const std::string& sDate, std::string & error) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MANTID_KERNEL_DLL DirectoryValidator : public FileValidator
explicit DirectoryValidator(bool testDirectoryExists = true);
virtual ~DirectoryValidator();
virtual std::set<std::string> allowedValues() const;
virtual IValidator<std::string>* clone();
virtual IValidator<std::string>* clone() const;

private:
virtual std::string checkValidity(const std::string &value) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MANTID_KERNEL_DLL FileValidator : public IValidator<std::string>
explicit FileValidator(const std::vector<std::string>& extensions, bool testFileExists = true);
virtual ~FileValidator();
virtual std::set<std::string> allowedValues() const;
virtual IValidator<std::string>* clone();
virtual IValidator<std::string>* clone() const;

protected:
/// The list of permitted extensions
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/inc/MantidKernel/IValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DLLExport IValidator
virtual std::set<std::string> allowedValues() const { return std::set<std::string>(); }

/// Make a copy of the present type of validator
virtual IValidator* clone() = 0;
virtual IValidator* clone() const = 0;


protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class ListAnyValidator : public IValidator<TYPE>
}

/// Clone this validator
virtual IValidator<TYPE>* clone(){ return new ListAnyValidator<TYPE>(*this); }
virtual IValidator<TYPE>* clone() const{ return new ListAnyValidator<TYPE>(*this); }

protected:
/** Checks if the value passed is in the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ListValidator : public ListAnyValidator<std::string>

virtual ~ListValidator(){};

virtual IValidator<std::string>* clone(){ return new ListValidator(*this); }
virtual IValidator<std::string>* clone() const { return new ListValidator(*this); }


protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ template< class TYPE >
class DLLExport MandatoryValidator : public IValidator<TYPE>
{
public:
IValidator<TYPE>* clone() { return new MandatoryValidator(*this); }
IValidator<TYPE>* clone() const { return new MandatoryValidator(*this); }

private:
/** Checks if the string is empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MANTID_KERNEL_DLL MultiFileValidator : public IValidator<std::vector<std::
explicit MultiFileValidator(const std::vector<std::string>& extensions);
virtual ~MultiFileValidator();

virtual IValidator<std::vector<std::vector<std::string> > >* clone();
virtual IValidator<std::vector<std::vector<std::string> > >* clone() const;

/// Returns the set of allowed extensions.
virtual std::set<std::string> allowedValues() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ template <typename TYPE>
class DLLExport NullValidator : public IValidator<TYPE>
{
public:
IValidator<TYPE>* clone() { return new NullValidator(*this); }
IValidator<TYPE>* clone() const { return new NullValidator(*this); }

private:
/** Always returns valid, that is ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MANTID_KERNEL_DLL RebinParamsValidator : public IValidator<std::vector<dou
public:
RebinParamsValidator() {}
virtual ~RebinParamsValidator() {}
Kernel::IValidator<std::vector<double> >* clone() { return new RebinParamsValidator(*this); }
Kernel::IValidator<std::vector<double> >* clone() const { return new RebinParamsValidator(*this); }

private:
std::string checkValidity( const std::vector<double> &value ) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ValidatorAnyList : public IValidator<TYPE>
m_allowedValues.insert(value);
}

IValidator<TYPE>* clone() { return new ValidatorAnyList<TYPE>(*this); }
IValidator<TYPE>* clone() const { return new ValidatorAnyList<TYPE>(*this); }

private:
/** Checks if the string passed is in the list
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/ArrayBoundedValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ArrayBoundedValidator<TYPE>::~ArrayBoundedValidator()
* @return the cloned object
*/
template <typename TYPE>
IValidator<std::vector<TYPE> >* ArrayBoundedValidator<TYPE>::clone()
IValidator<std::vector<TYPE> >* ArrayBoundedValidator<TYPE>::clone() const
{
return new ArrayBoundedValidator<TYPE>(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/ArrayLengthValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ ArrayLengthValidator<TYPE>::ArrayLengthValidator():IValidator<std::vector<TYPE>
@returns a clone of the validator
*/
template <typename TYPE>
IValidator<std::vector <TYPE> >* ArrayLengthValidator<TYPE>::clone()
IValidator<std::vector <TYPE> >* ArrayLengthValidator<TYPE>::clone() const
{
return new ArrayLengthValidator(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/DateValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DateValidator::~DateValidator()
}

/// create a copy of the the validator
IValidator<std::string> *DateValidator::clone()
IValidator<std::string> *DateValidator::clone() const
{
return new DateValidator(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/DirectoryValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ std::set<std::string> DirectoryValidator::allowedValues() const
* Clone the validator
* @returns A pointer to a new validator with the same properties as this one
*/
IValidator<std::string>* DirectoryValidator::clone()
IValidator<std::string>* DirectoryValidator::clone() const
{
return new DirectoryValidator(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/FileValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ std::set<std::string> FileValidator::allowedValues() const
* Clone the validator
* @returns A pointer to a new validator with the same properties as this one
*/
IValidator<std::string>* FileValidator::clone()
IValidator<std::string>* FileValidator::clone() const
{
return new FileValidator(*this);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/MultiFileValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Kernel
* Clone the validator
* @returns A pointer to a new validator with the same properties as this one
*/
IValidator<std::vector<std::vector<std::string> > >* MultiFileValidator::clone()
IValidator<std::vector<std::vector<std::string> > >* MultiFileValidator::clone() const
{
return new MultiFileValidator(*this);
}
Expand Down

0 comments on commit 5c04f6d

Please sign in to comment.