Debian Codegraph @

Source/Reasoner/Ontology/COntologyProcessingStepVector.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 "COntologyProcessingStepVector.h"
22 #include "COntologyProcessingStepRequirement.h"
23
24
25 namespace Konclude {
26
27 namespace Reasoner {
28
29 namespace Ontology {
30
31
32 QMutex* COntologyProcessingStepVector::mInstanceMutex = new QMutex();
33 COntologyProcessingStepVector* COntologyProcessingStepVector::mProcStepVectorInstance = nullptr;
34
35
36 COntologyProcessingStepVector::COntologyProcessingStepVector() {
37 mPrStCount = 0;
38 }
39
40
41 COntologyProcessingStepVector* COntologyProcessingStepVector::initDefaultProcessingSteps() {
42 COntologyProcessingStep* stepTriplesMapping = new COntologyProcessingStep(COntologyProcessingStep::OPSTRIPLESMAPPING, mPrStCount, COntologyProcessingStep::OPPREPROCESSOR);
43 addProcessingSteps(stepTriplesMapping);
44
45 COntologyProcessingStep* activeBuild = new COntologyProcessingStep(COntologyProcessingStep::OPSACTIVECOUNT,mPrStCount,COntologyProcessingStep::OPPREPROCESSOR);
46 activeBuild->addProcessingRequirement(new COntologyProcessingStepRequirement(stepTriplesMapping, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
47 addProcessingSteps(activeBuild);
48
49 COntologyProcessingStep* stepBuild = new COntologyProcessingStep(COntologyProcessingStep::OPSBUILD,mPrStCount,COntologyProcessingStep::OPPREPROCESSOR);
50 stepBuild->addProcessingRequirement(new COntologyProcessingStepRequirement(stepTriplesMapping, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
51 addProcessingSteps(stepBuild);
52
53 COntologyProcessingStep* stepPreprocess = new COntologyProcessingStep(COntologyProcessingStep::OPSPREPROCESS,mPrStCount,COntologyProcessingStep::OPPREPROCESSOR);
54 stepPreprocess->addProcessingRequirement(new COntologyProcessingStepRequirement(stepBuild, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
55 stepPreprocess->addProcessingRequirement(new COntologyProcessingStepRequirement(activeBuild, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
56 addProcessingSteps(stepPreprocess);
57
58
59 COntologyProcessingStep* stepIndexing = new COntologyProcessingStep(COntologyProcessingStep::OPSTRIPLESINDEXING, mPrStCount, COntologyProcessingStep::OPPREPROCESSOR);
60 stepIndexing->addProcessingRequirement(new COntologyProcessingStepRequirement(stepPreprocess, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
61 addProcessingSteps(stepIndexing);
62
63 COntologyProcessingStep* stepConsistency = new COntologyProcessingStep(COntologyProcessingStep::OPSCONSISTENCY,mPrStCount,COntologyProcessingStep::OPPRECOMPUTER);
64 stepConsistency->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndexing, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
65 addProcessingSteps(stepConsistency);
66
67
68
69 COntologyProcessingStep* stepIndividualComp = new COntologyProcessingStep(COntologyProcessingStep::OPSPRECOMPUTEINDIVIDUAL,mPrStCount,COntologyProcessingStep::OPPRECOMPUTER);
70 stepIndividualComp->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
71 addProcessingSteps(stepIndividualComp);
72
73
74
75 COntologyProcessingStep* stepSaturation = new COntologyProcessingStep(COntologyProcessingStep::OPSPRECOMPUTESATURATION,mPrStCount,COntologyProcessingStep::OPPRECOMPUTER);
76 stepSaturation->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
77 stepSaturation->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndividualComp, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
78 addProcessingSteps(stepSaturation);
79
80 COntologyProcessingStep* stepCycles = new COntologyProcessingStep(COntologyProcessingStep::OPSPRECOMPUTECYCLES,mPrStCount,COntologyProcessingStep::OPPRECOMPUTER);
81 stepCycles->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
82 stepCycles->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndividualComp, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
83 addProcessingSteps(stepCycles);
84
85
86 COntologyProcessingStep* stepOccStats = new COntologyProcessingStep(COntologyProcessingStep::OPSPRECOMPUTEOCCURRENCESTATISTICS, mPrStCount, COntologyProcessingStep::OPPRECOMPUTER);
87 stepOccStats->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
88 stepOccStats->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndividualComp, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
89 addProcessingSteps(stepOccStats);
90
91
92
93 COntologyProcessingStep* stepClassify = new COntologyProcessingStep(COntologyProcessingStep::OPSCLASSCLASSIFY,mPrStCount,COntologyProcessingStep::OPCLASSCLASSIFIER);
94 stepClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
95 stepClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepSaturation, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
96 stepClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepCycles, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
97 stepClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndividualComp, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
98 addProcessingSteps(stepClassify);
99
100
101
102 COntologyProcessingStep* stepObjPropClassify = new COntologyProcessingStep(COntologyProcessingStep::OPSOBJECTROPERTYCLASSIFY,mPrStCount,COntologyProcessingStep::OPOBJECTPROPERTYCLASSIFIER);
103 stepObjPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
104 stepObjPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepSaturation, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
105 stepObjPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepCycles, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
106 stepObjPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndividualComp, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
107 addProcessingSteps(stepObjPropClassify);
108
109
110
111 COntologyProcessingStep* stepDataPropClassify = new COntologyProcessingStep(COntologyProcessingStep::OPSDATAROPERTYCLASSIFY,mPrStCount,COntologyProcessingStep::OPDATAPROPERTYCLASSIFIER);
112 stepDataPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepConsistency, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
113 stepDataPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepSaturation, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
114 stepDataPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepCycles, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
115 stepDataPropClassify->addProcessingRequirement(new COntologyProcessingStepRequirement(stepIndividualComp, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
116 addProcessingSteps(stepDataPropClassify);
117
118
119
120 COntologyProcessingStep* initRealize = new COntologyProcessingStep(COntologyProcessingStep::OPSINITREALIZE, mPrStCount, COntologyProcessingStep::OPREALIZER);
121 initRealize->addProcessingRequirement(new COntologyProcessingStepRequirement(stepClassify, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
122 initRealize->addProcessingRequirement(new COntologyProcessingStepRequirement(stepObjPropClassify, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
123 addProcessingSteps(initRealize);
124
125 COntologyProcessingStep* stepRealizeConcepts = new COntologyProcessingStep(COntologyProcessingStep::OPSCONCEPTREALIZE,mPrStCount,COntologyProcessingStep::OPREALIZER);
126 stepRealizeConcepts->addProcessingRequirement(new COntologyProcessingStepRequirement(initRealize, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
127 addProcessingSteps(stepRealizeConcepts);
128
129 COntologyProcessingStep* stepRealizeRoles = new COntologyProcessingStep(COntologyProcessingStep::OPSROLEREALIZE,mPrStCount,COntologyProcessingStep::OPREALIZER);
130 stepRealizeRoles->addProcessingRequirement(new COntologyProcessingStepRequirement(initRealize, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
131 addProcessingSteps(stepRealizeRoles);
132
133 COntologyProcessingStep* stepRealizeSameIndividuals = new COntologyProcessingStep(COntologyProcessingStep::OPSSAMEINDIVIDUALSREALIZE,mPrStCount,COntologyProcessingStep::OPREALIZER);
134 stepRealizeSameIndividuals->addProcessingRequirement(new COntologyProcessingStepRequirement(initRealize, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0));
135 addProcessingSteps(stepRealizeSameIndividuals);
136
137 COntologyProcessingStep* stepAnswerComplexQueries = new COntologyProcessingStep(COntologyProcessingStep::OPSANSWERCOMPLEXQUERY, mPrStCount, COntologyProcessingStep::OPANSWERER);
138 stepAnswerComplexQueries->addProcessingRequirement(new COntologyProcessingStepRequirement(stepOccStats, COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, COntologyProcessingStatus::PSINCONSITENT));
139 addProcessingSteps(stepAnswerComplexQueries);
140
141 return this;
142 }
143
144
145 COntologyProcessingStepVector* COntologyProcessingStepVector::addProcessingSteps(COntologyProcessingStep* proStepData) {
146 mPrStepVector.append(proStepData);
147 ++mPrStCount;
148 return this;
149 }
150
151
152
153 COntologyProcessingStep* COntologyProcessingStepVector::getProcessingStep(cint64 stepID) {
154 if (stepID < 0 || stepID >= mPrStCount) {
155 return nullptr;
156 }
157 return mPrStepVector[stepID];
158 }
159
160 COntologyProcessingStep* COntologyProcessingStepVector::getProcessingStep(COntologyProcessingStep::PROCESSINGSTEPTYPE stepType) {
161 return getProcessingStep((cint64)stepType);
162 }
163
164
165 cint64 COntologyProcessingStepVector::getProcessingStepCount() {
166 return mPrStCount;
167 }
168
169
170 COntologyProcessingStepVector* COntologyProcessingStepVector::getProcessingStepVectorInstance() {
171 if (mProcStepVectorInstance == nullptr) {
172 mInstanceMutex->lock();
173 if (mProcStepVectorInstance == nullptr) {
174 mProcStepVectorInstance = new COntologyProcessingStepVector();
175 mProcStepVectorInstance->initDefaultProcessingSteps();
176 }
177 mInstanceMutex->unlock();
178 }
179 return mProcStepVectorInstance;
180 }
181
182
183 }; // end namespace Ontology
184
185 }; // end namespace Reasoner
186
187 }; // end namespace Konclude