Debian Codegraph @

Source/Reasoner/Consistiser/CDirectBlockedProcessingConsistiser.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 "CDirectBlockedProcessingConsistiser.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Consistiser {
29
30
31 CDirectBlockedProcessingConsistiser::CDirectBlockedProcessingConsistiser() : mConsAdapter(this) {
32 mConsistence = nullptr;
33 }
34
35
36 CDirectBlockedProcessingConsistiser::~CDirectBlockedProcessingConsistiser() {
37 }
38
39
40 bool CDirectBlockedProcessingConsistiser::determineConsistency(CConcreteOntology* onto, CConfiguration *config) {
41 QList<CIndividual*> indiList;
42 CIndividualVector* indiVec = onto->getABox()->getIndividualVector(false);
43 if (indiVec) {
44 cint64 indiCount = indiVec->getItemCount();
45 for (cint64 idx = 0; idx < indiCount; ++idx) {
46 CIndividual* indi = indiVec->getData(idx);
47 if (indi) {
48 indiList.append(indi);
49 }
50 }
51 }
52 CReasonerManager* reasonerManager = CConfigManagerReader::readReasonerManagerConfig(config);
53 CSatisfiableCalculationJobGenerator satCalcJobGen(onto);
54 CSatisfiableCalculationJob* satCalcJob = nullptr;
55 bool simpleConsistency = false;
56 if (indiList.isEmpty()) {
57 CConcept* topConcept = onto->getTBox()->getTopConcept();
58 if (topConcept->getOperandCount() > 0) {
59 satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(topConcept);
60 } else {
61 simpleConsistency = true;
62 }
63 } else {
64 satCalcJob = satCalcJobGen.getSatisfiableCalculationJob(indiList);
65 satCalcJob->setSatisfiableTaskPreyingAdapter(&mConsAdapter);
66 }
67 mConsistence = new CConsistence();
68 if (satCalcJob) {
69 CConfigurationBase* configBase = nullptr;
70 if (config) {
71 configBase = dynamic_cast<CConfigurationBase*>(config);
72 }
73 CCalculationConfigurationExtension calcConfig(configBase,0);
74 satCalcJob->setCalculationConfiguration(&calcConfig);
75 CJobSatisfiableResult* result = reasonerManager->reasoningSatisfiableCalcualtionJob(satCalcJob);
76 mConsistence->setOntologyConsistent(result->isSatisfiable());
77 } else {
78 mConsistence->setOntologyConsistent(simpleConsistency);
79 }
80 onto->setConsistence(mConsistence);
81
82 return this;
83 }
84
85
86 CConsistenceObserver* CDirectBlockedProcessingConsistiser::tellConsistenceData(CConsistenceData* consData) {
87 mSynMutex.lock();
88 if (!mConsistence->hasConsistenceModelData()) {
89 mConsistence->setConsistenceModelData(consData);
90 consData->overtakeData();
91 } else {
92 delete consData;
93 }
94 mSynMutex.unlock();
95 return this;
96 }
97
98
99 }; // end namespace Consistiser
100
101 }; // end namespace Reasoner
102
103 }; // end namespace Konclude