diff options
| author | 2020-01-30 01:27:15 +0100 | |
|---|---|---|
| committer | 2020-03-28 02:05:05 +0100 | |
| commit | 653ba9395a36cc20ec1d68c9a9cae78973fa334c (patch) | |
| tree | 72753ed3bdca117baf001cdf8251b1fb22276eeb /validator.h | |
| parent | 22d71d0032e2f44a8f267895aea3bd87864791b3 (diff) | |
| download | OneRoll-653ba9395a36cc20ec1d68c9a9cae78973fa334c.tar.gz OneRoll-653ba9395a36cc20ec1d68c9a9cae78973fa334c.zip | |
add unicity and repeat function part2
Diffstat (limited to 'validator.h')
| -rw-r--r-- | validator.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/validator.h b/validator.h index a1e7d65..c9f0b4c 100644 --- a/validator.h +++ b/validator.h @@ -31,6 +31,7 @@ * @brief The Validator class is an abstract class for checking the validity of dice for some * operator. */ +// template <Dice::ConditionType C> class Validator { public: @@ -66,11 +67,38 @@ public: * @return return a copy of this validator */ virtual Validator* getCopy() const= 0; - + /** + * @brief getPossibleValues + * @param range + * @return + */ virtual const std::set<qint64>& getPossibleValues(const std::pair<qint64, qint64>& range); + /** + * @brief validResult + * @param b + * @param recursive + * @param unlight + * @return + */ + template <typename Functor> + qint64 validResult(const std::vector<Die*>& b, bool recursive, bool unlight, Functor functor) const; + + Dice::ConditionType getConditionType() const; + void setConditionType(const Dice::ConditionType& conditionType); + +protected: + template <typename Functor> + qint64 onEach(const std::vector<Die*>& b, bool recursive, bool unlight, Functor functor) const; + template <typename Functor> + qint64 oneOfThem(const std::vector<Die*>& b, bool recursive, bool unlight, Functor functor) const; + template <typename Functor> + qint64 allOfThem(const std::vector<Die*>& b, bool recursive, bool unlight, Functor functor) const; + template <typename Functor> + qint64 onScalar(const std::vector<Die*>& b, bool recursive, bool unlight, Functor functor) const; protected: std::set<qint64> m_values; + Dice::ConditionType m_conditionType= Dice::OnEach; }; #endif // VALIDATOR_H |