Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationConfigurationLoader.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 "CReasonerEvaluationConfigurationLoader.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31 CReasonerEvaluationConfigurationLoader::CReasonerEvaluationConfigurationLoader() {
32 mLoaderConfig = nullptr;
33 mConfLogProcessingTimes = false;
34 }
35
36
37
38 CReasonerEvaluationConfigurationLoader::~CReasonerEvaluationConfigurationLoader() {
39 }
40
41
42 bool CReasonerEvaluationConfigurationLoader::loadConfiguration(const QString& owllinkConfigFile, CConfiguration *config) {
43 mLoaderConfig = config;
44 mReqFileString = owllinkConfigFile;
45
46 mBlockUntilProcessed = true;
47 mConfLogProcessingTimes = false;
48 CConfigData* data = config->getLastConfigChange("Konclude.OWLlink.LoggingExtendedProcessingTimes");
49 if (data) {
50 mConfLogProcessingTimes = data->getBoolean();
51 }
52
53 reasonerCommander = CConfigManagerReader::readCommanderManagerConfig(config);
54
55 mConfigSucessfullyLoaded = false;
56
57 startProcessing();
58 if (mBlockUntilProcessed) {
59 mBlockingSem.acquire();
60 }
61 stopThread();
62 return mConfigSucessfullyLoaded;
63 }
64
65
66
67
68 CConfiguration* CReasonerEvaluationConfigurationLoader::getConfiguration() {
69 if (!reasonerCommander) {
70 return mLoaderConfig;
71 } else {
72 CGetDescriptionCommand *getDesComm = new CGetDescriptionCommand();
73 reasonerCommander->delegateCommand(getDesComm);
74 CCommandExecutedBlocker commExeBlocker;
75 commExeBlocker.waitExecutedCommand(getDesComm);
76 CConfiguration *config = getDesComm->getConfiguration();
77 return config;
78 }
79 }
80
81
82
83 COWLlinkProcessor* CReasonerEvaluationConfigurationLoader::initializeOWLlinkContent() {
84 mResponseTime.start();
85 if (!mReqFileString.isEmpty()) {
86 QFile file(mReqFileString);
87 LOG(INFO,getLogDomain(),logTr("Processing OWLlink configuration request from file '%1'.").arg(mReqFileString),this);
88 if (file.open(QIODevice::ReadOnly)) {
89 fileContent = file.readAll();
90 COWLlinkQtXMLCommandParser *owllinkCommandParser = new COWLlinkQtXMLCommandParser(mLoaderConfig);
91 defaultCommandDelegater = preSynchronizer;
92
93 CParseOWLlinkCommandsCommand *parseCommand = new CParseOWLlinkCommandsCommand(&fileContent,mReqFileString);
94 parseCommand->setReportErrorFromSubCommands(false);
95
96 CCommandProcessedCallbackEvent *proComm = new CCommandProcessedCallbackEvent(this,parseCommand);
97 parseCommand->addProcessedCallback(proComm);
98
99
100 owllinkCommandParser->realizeCommand(parseCommand,preSynchronizer);
101
102 delete owllinkCommandParser;
103
104 if (mConfLogProcessingTimes) {
105 cint64 readMilliSeconds = mResponseTime.elapsed();
106 LOG(INFO,getLogDomain(),logTr("Read XML content in %1 ms.").arg(readMilliSeconds),this);
107 }
108 file.close();
109
110 mConfigSucessfullyLoaded = true;
111
112 } else {
113 LOG(ERROR,getLogDomain(),logTr("OWLlink configuration request file '%1' not found.").arg(mReqFileString),this);
114 concludeOWLlinkContent();
115 }
116 }
117 return this;
118 }
119
120
121
122 COWLlinkProcessor* CReasonerEvaluationConfigurationLoader::concludeOWLlinkContent() {
123 if (mConfLogProcessingTimes) {
124 cint64 responseMilliSeconds = mResponseTime.elapsed();
125 LOG(INFO,getLogDomain(),logTr("OWLlink request processed in %1 ms.").arg(responseMilliSeconds),this);
126 }
127 if (mBlockUntilProcessed) {
128 mBlockingSem.release();
129 }
130 return this;
131 }
132
133
134 }; // end namespace Evaluation
135
136 }; // end namespace Test
137
138 }; // end namespace Konclude