/* * VectorRangeValidator.hpp * * Created on: Apr 13, 2012 * Author: ankele */ #ifndef VECTORRANGEVALIDATOR_HPP_ #define VECTORRANGEVALIDATOR_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Validator.hpp" #include "CodePatterns/Range.hpp" /** A validator with an interval of valid values. * */ template class VectorRangeValidator : public Validator { public: VectorRangeValidator(const range &_ValidRange) : ValidRange(_ValidRange) {}; virtual ~VectorRangeValidator() {}; bool isValid(const T & _value) const { return ValidRange.first[0] <= _value[0] && _value[0] < ValidRange.last[0] && ValidRange.first[1] <= _value[1] && _value[1] < ValidRange.last[1] && ValidRange.first[2] <= _value[2] && _value[2] < ValidRange.last[2]; } Validator* clone() const { return new RangeValidator(ValidRange); }; // comparator bool operator==(const Validator &_instance) const { const VectorRangeValidator *inst = dynamic_cast *>(&_instance); if (inst) return ValidRange == inst->ValidRange; return false; }; private: //!> valid range of values range ValidRange; }; #endif /* VECTORRANGEVALIDATOR_HPP_ */