Debian Codegraph @

Source/Reasoner/Answerer/CComplexConceptItemComputationProcess.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 "CComplexConceptItemComputationProcess.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Answerer {
29
30
31 CComplexConceptItemComputationProcess::CComplexConceptItemComputationProcess() {
32 for (cint64 i = 0; i < COMPLEXCONCEPTSTEPCOMPUTATIONPROCESSTYPECOUNT; ++i) {
33 mComputationProcessArray[i] = nullptr;
34 }
35 }
36
37
38 CComplexConceptItemComputationProcess::~CComplexConceptItemComputationProcess() {
39 }
40
41
42 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getSatisfiableClassNodesComputationProcess(bool create) {
43 return getComputationProcess(COMPUTATIONTYPESATISFIABILITY);
44 }
45
46
47 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getSuperClassNodesComputationProcess(bool create) {
48 return getComputationProcess(COMPUTATIONTYPESUPERCLASSNODES);
49 }
50
51 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getSubClassNodesComputationProcess(bool create) {
52 return getComputationProcess(COMPUTATIONTYPESUBCLASSNODES);
53 }
54
55 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getSubClassRealizationProcess(bool create) {
56 return getComputationProcess(REALIZATIONTYPESUBCLASS);
57 }
58
59
60 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getEquivalentClassNodesComputationProcess(bool create) {
61 return getComputationProcess(COMPUTATIONTYPEEQUIVALENTCLASSNODES);
62 }
63
64
65 CComplexConceptStepInstanceComputationProcess* CComplexConceptItemComputationProcess::getInstancesComputationProcess(bool create) {
66 return (CComplexConceptStepInstanceComputationProcess*)getComputationProcess(COMPUTATIONTYPEINSTANCES);
67 }
68
69
70 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getComputationProcess(ComplexConceptStepComputationProcessType computationType, bool create) {
71 if (computationType < 0 || computationType >= COMPLEXCONCEPTSTEPCOMPUTATIONPROCESSTYPECOUNT) {
72 return nullptr;
73 }
74 if (create && !mComputationProcessArray[computationType]) {
75 if (computationType == COMPUTATIONTYPEINSTANCES) {
76 mComputationProcessArray[computationType] = new CComplexConceptStepInstanceComputationProcess();
77 } else {
78 mComputationProcessArray[computationType] = new CComplexConceptStepComputationProcess(computationType);
79 }
80 }
81 return mComputationProcessArray[computationType];
82 }
83
84
85 bool CComplexConceptItemComputationProcess::isComputationRequired(ComplexConceptStepComputationProcessType computationType) {
86 if (computationType < 0 || computationType >= COMPLEXCONCEPTSTEPCOMPUTATIONPROCESSTYPECOUNT) {
87 return false;
88 }
89 if (!mComputationProcessArray[computationType]) {
90 return false;
91 }
92 if (mComputationProcessArray[computationType]->isComputationProcessRequired()) {
93 return true;
94 }
95 if (computationType == COMPUTATIONTYPEINSTANCES) {
96 return getInstancesComputationProcess(true)->requiresAdditionalInstanceComputation();
97 }
98 return false;
99 }
100
101
102 bool CComplexConceptItemComputationProcess::isComputationFinished(ComplexConceptStepComputationProcessType computationType) {
103 if (computationType < 0 || computationType >= COMPLEXCONCEPTSTEPCOMPUTATIONPROCESSTYPECOUNT) {
104 return false;
105 }
106 if (!mComputationProcessArray[computationType]) {
107 return false;
108 }
109 return mComputationProcessArray[computationType]->isComputationProcessFinished();
110 }
111
112
113 bool CComplexConceptItemComputationProcess::isComputationStarted(ComplexConceptStepComputationProcessType computationType) {
114 if (computationType < 0 || computationType >= COMPLEXCONCEPTSTEPCOMPUTATIONPROCESSTYPECOUNT) {
115 return false;
116 }
117 if (!mComputationProcessArray[computationType]) {
118 return false;
119 }
120 return mComputationProcessArray[computationType]->isComputationProcessStarted();
121 }
122
123
124
125
126 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getNextConceptStepComputationProcess(ComplexConceptStepComputationProcessType type, bool onlyRequired) {
127 while ((cint64)type + 1 < COMPLEXCONCEPTSTEPCOMPUTATIONPROCESSTYPECOUNT) {
128 type = (ComplexConceptStepComputationProcessType)(type + 1);
129 if (!onlyRequired || isComputationRequired(type)) {
130 return mComputationProcessArray[type];
131 }
132 }
133 return nullptr;
134 }
135
136
137 CComplexConceptStepComputationProcess* CComplexConceptItemComputationProcess::getNextConceptStepComputationProcess(CComplexConceptStepComputationProcess* step, bool onlyRequired) {
138 return getNextConceptStepComputationProcess(step->getComputationType(), onlyRequired);
139 }
140
141 }; // end namespace Answerer
142
143 }; // end namespace Reasoner
144
145 }; // end namespace Konclude