diff options
| author | 2020-03-28 01:08:11 +0000 | |
|---|---|---|
| committer | 2020-03-28 01:08:11 +0000 | |
| commit | 944072519b4e7bc31e93024ece61b1079f7427a5 (patch) | |
| tree | 522475f7c4d5dade1c0b3482ab35d3f625b99ebe /validator.h | |
| parent | 932d863c2a2c9b08d8ce1f4e1041e5795daedc6d (diff) | |
| parent | 088b2fa45dc2c763187109ec7d77f9eb096e498e (diff) | |
| download | OneRoll-944072519b4e7bc31e93024ece61b1079f7427a5.tar.gz OneRoll-944072519b4e7bc31e93024ece61b1079f7427a5.zip | |
Merge branch 'repeat2' into 'master'
All new features
See merge request kde/rolisteam-diceparser!4
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 |