File indexing completed on 2025-01-26 03:44:29
0001 /* 0002 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KUSERFEEDBACK_SURVEYTARGETEXPRESSIONEVALUATOR_H 0008 #define KUSERFEEDBACK_SURVEYTARGETEXPRESSIONEVALUATOR_H 0009 0010 #include <QHash> 0011 0012 QT_BEGIN_NAMESPACE 0013 class QString; 0014 class QVariant; 0015 QT_END_NAMESPACE 0016 0017 namespace KUserFeedback { 0018 0019 class SurveyTargetExpression; 0020 0021 class SurveyTargetExpressionDataProvider 0022 { 0023 public: 0024 SurveyTargetExpressionDataProvider(); 0025 virtual ~SurveyTargetExpressionDataProvider(); 0026 virtual QVariant sourceData(const QString &sourceName) const = 0; 0027 0028 private: 0029 Q_DISABLE_COPY(SurveyTargetExpressionDataProvider) 0030 }; 0031 0032 class SurveyTargetExpressionEvaluator 0033 { 0034 public: 0035 SurveyTargetExpressionEvaluator(); 0036 ~SurveyTargetExpressionEvaluator(); 0037 0038 void setDataProvider(const SurveyTargetExpressionDataProvider *provider); 0039 0040 bool evaluate(SurveyTargetExpression *expression); 0041 0042 private: 0043 QVariant value(SurveyTargetExpression *expression); 0044 QVariant value(const QString &source); 0045 0046 const SurveyTargetExpressionDataProvider *m_provider; 0047 QHash<QString, QVariant> m_dataCache; 0048 }; 0049 0050 } 0051 0052 #endif // KUSERFEEDBACK_SURVEYTARGETEXPRESSIONEVALUATOR_H