File indexing completed on 2024-04-28 05:36:59

0001 /***************************************************************************
0002  * Copyright (C) 2014 by Renaud Guezennec                                   *
0003  * https://rolisteam.org/contact                      *
0004  *                                                                          *
0005  *  This file is part of DiceParser                                         *
0006  *                                                                          *
0007  * DiceParser is free software; you can redistribute it and/or modify       *
0008  * it under the terms of the GNU General Public License as published by     *
0009  * the Free Software Foundation; either version 2 of the License, or        *
0010  * (at your option) any later version.                                      *
0011  *                                                                          *
0012  * This program is distributed in the hope that it will be useful,          *
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of           *
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
0015  * GNU General Public License for more details.                             *
0016  *                                                                          *
0017  * You should have received a copy of the GNU General Public License        *
0018  * along with this program; if not, write to the                            *
0019  * Free Software Foundation, Inc.,                                          *
0020  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.                 *
0021  ***************************************************************************/
0022 #ifndef COMPOSITEVALIDATOR_H
0023 #define COMPOSITEVALIDATOR_H
0024 
0025 #include <QList>
0026 #include <QString>
0027 #include <QVector>
0028 #include <Qt>
0029 
0030 #include "validator.h"
0031 /**
0032  * @brief The BooleanCondition class is a Validator class checking validity from logic expression.
0033  * It manages many operators (see : @ref LogicOperator).
0034  */
0035 class CompositeValidator : public Validator
0036 {
0037 public:
0038     enum LogicOperation
0039     {
0040         OR,
0041         EXCLUSIVE_OR,
0042         AND,
0043         NONE
0044     };
0045     CompositeValidator();
0046     virtual ~CompositeValidator() override;
0047 
0048     virtual qint64 hasValid(Die* b, bool recursive, bool unhighlight= false) const override;
0049 
0050     void setOperationList(const QVector<LogicOperation>& m);
0051     void setValidatorList(const QList<Validator*>& valids);
0052 
0053     QString toString() override;
0054 
0055     virtual Dice::CONDITION_STATE isValidRangeSize(const std::pair<qint64, qint64>& range) const override;
0056 
0057     virtual Validator* getCopy() const override;
0058 
0059 private:
0060     QVector<LogicOperation> m_operators;
0061     QList<Validator*> m_validatorList;
0062 };
0063 
0064 #endif // BOOLEANCONDITION_H