Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationStatisticsNameCollectingExtractor.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 "CReasonerEvaluationStatisticsNameCollectingExtractor.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31
32 CReasonerEvaluationStatisticsNameCollectingExtractor::CReasonerEvaluationStatisticsNameCollectingExtractor(QSet<QString>* statisticsNamesSet, CReasonerEvaluationDataValueCacher* cacher) {
33 mCacher = cacher;
34
35 mStatisticsNamesSet = statisticsNamesSet;
36 }
37
38
39
40
41 bool CReasonerEvaluationStatisticsNameCollectingExtractor::extractEvaluationData(QDomDocument& document, const QString& responseFileString) {
42
43 QDomElement rootEl = document.documentElement();
44
45
46 QList<QDomElement> elementList;
47 elementList.append(rootEl);
48
49 cint64 queryNumber = 0;
50
51 while (!elementList.isEmpty()) {
52
53 QDomElement element = elementList.takeFirst();
54
55 if (element.hasAttribute("statistic-name")) {
56 QString statName = element.attribute("statistic-name");
57 mStatisticsNamesSet->insert(statName);
58 }
59 if (element.hasAttribute("request-command")) {
60 QString statName = element.attribute("request-command");
61 ++queryNumber;
62 if (statName == "Classify") {
63 mStatisticsNamesSet->insert(QString("query-%1-classify-response-time").arg(queryNumber));
64 } else if (statName == "Realize") {
65 mStatisticsNamesSet->insert(QString("query-%1-realize-response-time").arg(queryNumber));
66 } else if (statName == "IsKBSatisfiable") {
67 mStatisticsNamesSet->insert(QString("query-%1-consistency-response-time").arg(queryNumber));
68 }
69
70 }
71
72 QDomElement childElement = element.firstChildElement();
73 while (!childElement.isNull()) {
74 elementList.append(childElement);
75 childElement = childElement.nextSiblingElement();
76 }
77 }
78 return true;
79 }
80
81
82 CReasonerEvaluationDataValue* CReasonerEvaluationStatisticsNameCollectingExtractor::extractEvaluationData(const QString& responseFileString) {
83
84 QFile responseFile(responseFileString);
85 if (responseFile.open(QIODevice::ReadOnly)) {
86 QDomDocument document;
87 document.setContent(&responseFile,false);
88 extractEvaluationData(document,responseFileString);
89 responseFile.close();
90 }
91
92
93 return nullptr;
94 }
95
96
97 }; // end namespace Evaluation
98
99 }; // end namespace Test
100
101 }; // end namespace Konclude