Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationFilter.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CReasonerEvaluationFilter.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31
32 CReasonerEvaluationFilter::CReasonerEvaluationFilter() {
33 }
34
35
36 bool CReasonerEvaluationFilter::loadFilterConditionFile(const QString& filterNameString) {
37 QFile filterFile(filterNameString);
38 if (filterFile.open(QIODevice::ReadOnly)) {
39 while (!filterFile.atEnd()) {
40 QByteArray filterLine(filterFile.readLine());
41 QStringList filterDataList = QString(filterLine).trimmed().split("\t");
42 if (filterDataList.count() >= 4) {
43 CReasonerEvaluationFilterCondition* statExtCon = nullptr;
44 QString filterTypeString = filterDataList.takeFirst().toUpper();
45 QString filterNameString = filterDataList.takeFirst();
46 QString filterComperatorString = filterDataList.takeFirst();
47 QString filterCompareValueString = filterDataList.takeFirst();
48 if (filterTypeString == "INTEGER") {
49 statExtCon = new CReasonerEvaluationFilterIntegerCondition(filterNameString,filterComperatorString,filterCompareValueString);
50 } else if (filterTypeString == "STRING") {
51 statExtCon = new CReasonerEvaluationFilterStringCondition(filterNameString,filterComperatorString,filterCompareValueString);
52 }
53 if (statExtCon) {
54 mCondList.append(statExtCon);
55 }
56 }
57 }
58 filterFile.close();
59 return true;
60 }
61 return false;
62 }
63
64
65
66
67 bool CReasonerEvaluationFilter::testSatisfiesFilterConditions(const QString& testFileNameString, const QString& testFilePathString, const QString& subDirPathString, const QStringList& statisticList) {
68 QStringList extStatisticList;
69 extStatisticList.append(QString("Path:\t")+testFilePathString+subDirPathString);
70 extStatisticList.append(QString("RelativeTestPath:\t")+subDirPathString);
71 extStatisticList.append(QString("BaseTestPath:\t")+testFilePathString);
72 extStatisticList.append(QString("FileName:\t")+testFileNameString);
73 extStatisticList.append(QString("PathFileName:\t")+testFilePathString+subDirPathString+testFileNameString);
74 extStatisticList.append(statisticList);
75 return testSatisfiesFilterConditions(extStatisticList);
76 }
77
78
79 bool CReasonerEvaluationFilter::testSatisfiesFilterConditions(const QString& testFileNameString, const QStringList& statisticList) {
80 QStringList extStatisticList;
81 QString fileNameString = testFileNameString;
82 QString pathString;
83 cint64 lastSlash = testFileNameString.lastIndexOf("/");
84 if (!lastSlash) {
85 pathString = testFileNameString.mid(0,lastSlash);
86 fileNameString = testFileNameString.mid(lastSlash+1);
87 }
88 extStatisticList.append(QString("Path:\t")+pathString);
89 extStatisticList.append(QString("FileName:\t")+fileNameString);
90 extStatisticList.append(QString("PathFileName:\t")+testFileNameString);
91 extStatisticList.append(statisticList);
92 return testSatisfiesFilterConditions(extStatisticList);
93 }
94
95
96 bool CReasonerEvaluationFilter::testSatisfiesFilterConditions(const QStringList& statisticList) {
97 foreach (CReasonerEvaluationFilterCondition* extrCond, mCondList) {
98 if (!extrCond->isStatisticConditionSatisfied(statisticList)) {
99 return false;
100 }
101 }
102 return true;
103 }
104
105
106
107 }; // end namespace Evaluation
108
109 }; // end namespace Test
110
111 }; // end namespace Konclude