Debian Codegraph @

Source/Reasoner/Kernel/Process/CReapplyConceptLabelSet.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 "CReapplyConceptLabelSet.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Kernel {
29
30 namespace Process {
31
32
33
34 CReapplyConceptLabelSet::CReapplyConceptLabelSet(CProcessContext* processContext) : mProcessContext(processContext),mConceptDesDepMap(processContext) {
35 mConceptDesLinker = nullptr;
36 mPrevConceptDesLinker = nullptr;
37 mCoreConDesLinker = nullptr;
38 mConceptCount = 0;
39 mAdditionalConceptDesDepMap = nullptr;
40 }
41
42
43 CReapplyConceptLabelSet::~CReapplyConceptLabelSet() {
44 }
45
46
47 CConceptSetFlags* CReapplyConceptLabelSet::getConceptFlags() {
48 return &mConceptFlags;
49 }
50
51
52 CConceptSetSignature* CReapplyConceptLabelSet::getConceptSignature() {
53 return &mConceptSignature;
54 }
55
56 CConceptSetStructure* CReapplyConceptLabelSet::getConceptStructure() {
57 return &mConceptStructure;
58 }
59
60 cint64 CReapplyConceptLabelSet::getConceptSignatureValue() {
61 return mConceptSignature.getSignatureValue();
62 }
63
64
65 CReapplyConceptLabelSet* CReapplyConceptLabelSet::initConceptLabelSet(CReapplyConceptLabelSet* prevConceptLabelSet) {
66 if (prevConceptLabelSet) {
67 mConceptDesLinker = prevConceptLabelSet->mConceptDesLinker;
68 mPrevConceptDesLinker = mConceptDesLinker;
69 mConceptCount = prevConceptLabelSet->mConceptCount;
70 if (!prevConceptLabelSet->mAdditionalConceptDesDepMap && prevConceptLabelSet->mConceptDesDepMap.size() <= 50 || prevConceptLabelSet->mAdditionalConceptDesDepMap && prevConceptLabelSet->mConceptDesDepMap.size()*10 < prevConceptLabelSet->mAdditionalConceptDesDepMap->size()) {
71 mConceptDesDepMap = prevConceptLabelSet->mConceptDesDepMap;
72 mAdditionalConceptDesDepMap = prevConceptLabelSet->mAdditionalConceptDesDepMap;
73 } else {
74 mConceptDesDepMap.clear();
75 if (prevConceptLabelSet->mAdditionalConceptDesDepMap) {
76 mAdditionalConceptDesDepMap = CObjectParameterizingAllocator< CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>,CProcessContext* >::allocateAndConstructAndParameterize(mProcessContext->getMemoryAllocationManager(),mProcessContext);
77 *mAdditionalConceptDesDepMap = *prevConceptLabelSet->mAdditionalConceptDesDepMap;
78 for (CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator it = prevConceptLabelSet->mConceptDesDepMap.constBegin(), itEnd = prevConceptLabelSet->mConceptDesDepMap.constEnd(); it != itEnd; ++it) {
79 cint64 conTag = it.key();
80 const CConceptDescriptorDependencyReapplyData& conData = it.value();
81 (*mAdditionalConceptDesDepMap)[conTag] = conData;
82 }
83 } else {
84 mAdditionalConceptDesDepMap = &prevConceptLabelSet->mConceptDesDepMap;
85 }
86 }
87 mConceptFlags = prevConceptLabelSet->mConceptFlags;
88 mConceptSignature = prevConceptLabelSet->mConceptSignature;
89 mCoreConDesLinker = prevConceptLabelSet->mCoreConDesLinker;
90 mConceptStructure = prevConceptLabelSet->mConceptStructure;
91 } else {
92 mConceptDesDepMap.clear();
93 mAdditionalConceptDesDepMap = nullptr;
94 mConceptDesLinker = nullptr;
95 mPrevConceptDesLinker = nullptr;
96 mCoreConDesLinker = nullptr;
97 mConceptCount = 0;
98 mConceptFlags.reset();
99 mConceptSignature.reset();
100 mConceptStructure.reset();
101 }
102 return this;
103 }
104
105
106 CCoreConceptDescriptor* CReapplyConceptLabelSet::getCoreConceptDescriptorLinker() {
107 return mCoreConDesLinker;
108 }
109
110 CReapplyConceptLabelSet* CReapplyConceptLabelSet::addCoreConceptDescriptor(CCoreConceptDescriptor* coreConDes) {
111 mCoreConDesLinker = coreConDes->append(mCoreConDesLinker);
112 return this;
113 }
114
115 bool CReapplyConceptLabelSet::hasConceptDescriptor(CConceptDescriptor* conceptDescriptor) {
116 return hasConcept(conceptDescriptor->getConcept(),conceptDescriptor->getNegation());
117 }
118
119
120 bool CReapplyConceptLabelSet::containsConceptDescriptor(CConceptDescriptor* conceptDescriptor) {
121 return hasConceptDescriptor(conceptDescriptor);
122 }
123
124
125 bool CReapplyConceptLabelSet::hasConcept(CConcept* concept, bool negated) {
126 if (!mConceptFlags.containsConceptFlags(concept, negated)) {
127 return false;
128 }
129 cint64 conTag = concept->getConceptTag();
130 CConceptDescriptorDependencyReapplyData* conDesDepData = nullptr;
131 bool isContained = mConceptDesDepMap.tryGetValuePointer(conTag,conDesDepData);
132 if (!conDesDepData && mAdditionalConceptDesDepMap) {
133 isContained = mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,conDesDepData);
134 }
135 return isContained && conDesDepData->mConceptDescriptor && conDesDepData->mConceptDescriptor->isNegated() == negated;
136 }
137
138 bool CReapplyConceptLabelSet::hasConcept(CConcept* concept, bool* containsNegated) {
139 if (!mConceptFlags.containsConceptFlags(concept)) {
140 return false;
141 }
142 cint64 conTag = concept->getConceptTag();
143 CConceptDescriptorDependencyReapplyData* conDesDepData = nullptr;
144 bool isContained = mConceptDesDepMap.tryGetValuePointer(conTag,conDesDepData);
145 if (!conDesDepData && mAdditionalConceptDesDepMap) {
146 isContained = mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,conDesDepData);
147 }
148 if (isContained && containsNegated) {
149 *containsNegated = conDesDepData->mConceptDescriptor && conDesDepData->mConceptDescriptor->isNegated();
150 }
151 return isContained && conDesDepData->mConceptDescriptor;
152 }
153
154 bool CReapplyConceptLabelSet::containsConcept(CConcept* concept, bool* containsNegated) {
155 return hasConcept(concept,containsNegated);
156 }
157
158 bool CReapplyConceptLabelSet::containsConcept(CConcept* concept, bool negated) {
159 return hasConcept(concept,negated);
160 }
161
162
163
164 bool CReapplyConceptLabelSet::getConceptDescriptor(CConcept* concept, CConceptDescriptor*& conDes, CDependencyTrackPoint*& depTrackPoint) {
165 return getConceptDescriptor(concept->getConceptTag(),conDes,depTrackPoint);
166 }
167
168
169 bool CReapplyConceptLabelSet::getConceptDescriptor(cint64 conTag, CConceptDescriptor*& conDes, CDependencyTrackPoint*& depTrackPoint) {
170 CConceptDescriptorDependencyReapplyData* conDesDepData = nullptr;
171 bool contained = mConceptDesDepMap.tryGetValuePointer(conTag,conDesDepData);
172 if (!conDesDepData && mAdditionalConceptDesDepMap) {
173 contained = mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,conDesDepData);
174 }
175 if (contained) {
176 conDes = conDesDepData->mConceptDescriptor;
177 if (conDes) {
178 depTrackPoint = conDes->getDependencyTrackPoint();
179 } else {
180 depTrackPoint = nullptr;
181 }
182 contained &= conDes != nullptr;
183 }
184 return contained;
185 }
186
187
188 bool CReapplyConceptLabelSet::insertConceptIgnoreClash(CConceptDescriptor* conceptDescriptor, CDependencyTrackPoint* depTrackPoint, CCondensedReapplyQueueIterator* reapplyQueueIt) {
189 cint64 conTag = conceptDescriptor->getConceptTag();
190 CConceptDescriptorDependencyReapplyData& conDesDepData = mConceptDesDepMap[conTag];
191 if (mAdditionalConceptDesDepMap && !conDesDepData.mConceptDescriptor && conDesDepData.mPosNegReapplyQueue.isEmpty()) {
192 const CConceptDescriptorDependencyReapplyData& addConDesDepData = mAdditionalConceptDesDepMap->value(conTag);
193 conDesDepData = addConDesDepData;
194 }
195 conDesDepData.mConceptDescriptor = conceptDescriptor;
196 ++mConceptCount;
197 mConceptSignature.addConceptSignature(conceptDescriptor);
198 mConceptFlags.addConceptFlags(conceptDescriptor);
199 mConceptStructure.addedConcept(conceptDescriptor);
200 mConceptDesLinker = conceptDescriptor->append(mConceptDesLinker);
201 if (reapplyQueueIt) {
202 *reapplyQueueIt = conDesDepData.mPosNegReapplyQueue.getIterator(conceptDescriptor->isNegated(),true);
203 }
204 return true;
205 }
206
207
208
209
210 bool CReapplyConceptLabelSet::insertConceptGetClash(CConceptDescriptor* conceptDescriptor, CDependencyTrackPoint* depTrackPoint, CCondensedReapplyQueueIterator* reapplyQueueIt, CConceptDescriptor** clashedConDes, CDependencyTrackPoint** clashedDepTrackPoint) {
211 cint64 conTag = conceptDescriptor->getConceptTag();
212 bool containsAlready = false;
213 bool containFromAdditionMap = false;
214 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
215 mConceptDesDepMap.tryInsert(conTag,CConceptDescriptorDependencyReapplyData(conceptDescriptor),&containsAlready,&containedConDesDepData);
216 if (!containsAlready && mAdditionalConceptDesDepMap) {
217 const CConceptDescriptorDependencyReapplyData& addConDesDepData = mAdditionalConceptDesDepMap->value(conTag);
218 if (addConDesDepData.mConceptDescriptor || !addConDesDepData.mPosNegReapplyQueue.isEmpty()) {
219 *containedConDesDepData = addConDesDepData;
220 containsAlready = true;
221 containFromAdditionMap = true;
222 }
223 }
224 if (containedConDesDepData->mConceptDescriptor == nullptr) {
225 containedConDesDepData->mConceptDescriptor = conceptDescriptor;
226 containsAlready = false;
227 }
228 if (containsAlready) {
229 CConceptDescriptor* containsConDes = containedConDesDepData->mConceptDescriptor;
230 if (containsConDes->isNegated() != conceptDescriptor->isNegated()) {
231 if (clashedConDes) {
232 *clashedConDes = containsConDes;
233 }
234 if (clashedDepTrackPoint) {
235 *clashedDepTrackPoint = containsConDes->getDependencyTrackPoint();
236 }
237 }
238 return true;
239 } else {
240 ++mConceptCount;
241 mConceptFlags.addConceptFlags(conceptDescriptor);
242 mConceptSignature.addConceptSignature(conceptDescriptor);
243 mConceptStructure.addedConcept(conceptDescriptor);
244 mConceptDesLinker = conceptDescriptor->append(mConceptDesLinker);
245 if (reapplyQueueIt) {
246 *reapplyQueueIt = containedConDesDepData->mPosNegReapplyQueue.getIterator(conceptDescriptor->isNegated(),true);
247 //if (conceptDescriptor->isNegated()) {
248 // *reapplyQueueIt = containedConDesDepData->mNegReapplyQueue.getIterator(true);
249 //} else {
250 // *reapplyQueueIt = containedConDesDepData->mPosReapplyQueue.getIterator(true);
251 //}
252 }
253 return false;
254 }
255 }
256
257
258 CClashedConceptDescriptor* CReapplyConceptLabelSet::insertConceptReturnClash(CConceptDescriptor* conceptDescriptor, CDependencyTrackPoint* depTrackPoint, bool* hasContained, CCondensedReapplyQueueIterator* reapplyQueueIt) {
259 cint64 conTag = conceptDescriptor->getConceptTag();
260 bool containsAlready = false;
261 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
262 mConceptDesDepMap.tryInsert(conTag,CConceptDescriptorDependencyReapplyData(conceptDescriptor),&containsAlready,&containedConDesDepData);
263 if (!containsAlready && mAdditionalConceptDesDepMap) {
264 const CConceptDescriptorDependencyReapplyData& addConDesDepData = mAdditionalConceptDesDepMap->value(conTag);
265 if (addConDesDepData.mConceptDescriptor || !addConDesDepData.mPosNegReapplyQueue.isEmpty()) {
266 *containedConDesDepData = addConDesDepData;
267 containsAlready = true;
268 }
269 }
270 if (containedConDesDepData->mConceptDescriptor == nullptr) {
271 containedConDesDepData->mConceptDescriptor = conceptDescriptor;
272 containsAlready = false;
273 }
274 if (containsAlready) {
275 if (hasContained) {
276 *hasContained = true;
277 }
278 CConceptDescriptor* containsConDes = containedConDesDepData->mConceptDescriptor;
279 if (containsConDes->isNegated() != conceptDescriptor->isNegated()) {
280 CDependencyTrackPoint* containsDepTrackPoint = containsConDes->getDependencyTrackPoint();
281 // create clash
282 CClashedConceptDescriptor* clashDes1 = CObjectAllocator<CClashedConceptDescriptor>::allocateAndConstruct(CContext::getMemoryAllocationManager(mProcessContext));
283 clashDes1->initClashedConceptDescriptor(conceptDescriptor,depTrackPoint,0);
284 CClashedConceptDescriptor* clashDes2 = CObjectAllocator<CClashedConceptDescriptor>::allocateAndConstruct(CContext::getMemoryAllocationManager(mProcessContext));
285 clashDes2->initClashedConceptDescriptor(containsConDes,containsDepTrackPoint,0);
286 clashDes1->append(clashDes2);
287 return clashDes1;
288 }
289 } else {
290 if (hasContained) {
291 *hasContained = false;
292 }
293 ++mConceptCount;
294 mConceptFlags.addConceptFlags(conceptDescriptor);
295 mConceptSignature.addConceptSignature(conceptDescriptor);
296 mConceptStructure.addedConcept(conceptDescriptor);
297 mConceptDesLinker = conceptDescriptor->append(mConceptDesLinker);
298 if (reapplyQueueIt) {
299 *reapplyQueueIt = containedConDesDepData->mPosNegReapplyQueue.getIterator(conceptDescriptor->isNegated(),true);
300 //if (conceptDescriptor->isNegated()) {
301 // *reapplyQueueIt = containedConDesDepData->mNegReapplyQueue.getIterator(true);
302 //} else {
303 // *reapplyQueueIt = containedConDesDepData->mPosReapplyQueue.getIterator(true);
304 //}
305 }
306 }
307 return nullptr;
308 }
309
310
311 bool CReapplyConceptLabelSet::insertConceptThrowClashReturnContained(CConceptDescriptor* conceptDescriptor, CDependencyTrackPoint* depTrackPoint, CCondensedReapplyQueueIterator* reapplyQueueIt) {
312 bool contained = false;
313 CClashedConceptDescriptor* clash = insertConceptReturnClash(conceptDescriptor,depTrackPoint,&contained,reapplyQueueIt);
314 if (clash) {
315 throw clash;
316 }
317 return contained;
318 }
319
320
321
322 cint64 CReapplyConceptLabelSet::getConceptCount() {
323 return mConceptCount;
324 }
325
326
327
328 CReapplyConceptLabelSetIterator CReapplyConceptLabelSet::getConceptLabelSetIterator(bool getSorted, bool getDependencies, bool getAllStructure) {
329 if (getSorted || getDependencies || getAllStructure) {
330 if (mAdditionalConceptDesDepMap) {
331 return CReapplyConceptLabelSetIterator(mConceptCount,nullptr,mConceptDesDepMap.constBegin(),mConceptDesDepMap.constEnd(),mAdditionalConceptDesDepMap->constBegin(),mAdditionalConceptDesDepMap->constEnd(),!getAllStructure);
332 } else {
333 return CReapplyConceptLabelSetIterator(mConceptCount,nullptr,mConceptDesDepMap.constBegin(),mConceptDesDepMap.constEnd(),CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator(),CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator(),!getAllStructure);
334 }
335 } else {
336 return CReapplyConceptLabelSetIterator(mConceptCount,mConceptDesLinker,CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator(),CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator(),CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator(),CPROCESSMAP<cint64,CConceptDescriptorDependencyReapplyData>::const_iterator());
337 }
338 }
339
340 bool CReapplyConceptLabelSet::getConceptDescriptorAndReapplyQueue(CConcept* concept, CConceptDescriptor*& conDes, CDependencyTrackPoint*& depTrackPoint, CCondensedReapplyQueue*& reapplyQueue) {
341 cint64 conTag = concept->getConceptTag();
342 return getConceptDescriptorAndReapplyQueue(conTag,conDes,depTrackPoint,reapplyQueue);
343 }
344
345
346 bool CReapplyConceptLabelSet::getConceptDescriptorAndReapplyQueue(cint64 conTag, CConceptDescriptor*& conDes, CDependencyTrackPoint*& depTrackPoint, CCondensedReapplyQueue*& reapplyQueue) {
347 CConceptDescriptorDependencyReapplyData* conDesDepData = nullptr;
348 bool contained = mConceptDesDepMap.tryGetValuePointer(conTag,conDesDepData);
349 if (!conDesDepData && mAdditionalConceptDesDepMap) {
350 contained = mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,conDesDepData);
351 }
352 if (contained) {
353 conDes = conDesDepData->mConceptDescriptor;
354 reapplyQueue = &conDesDepData->mPosNegReapplyQueue;
355 if (conDes) {
356 depTrackPoint = conDes->getDependencyTrackPoint();
357 } else {
358 depTrackPoint = nullptr;
359 }
360 contained = conDes != nullptr;
361 }
362 return contained;
363 }
364
365
366 bool CReapplyConceptLabelSet::getConceptDescriptorOrReapplyQueue(CConcept* concept, CConceptDescriptor*& conDes, CDependencyTrackPoint*& depTrackPoint, CCondensedReapplyQueue*& reapplyQueue) {
367 cint64 conTag = concept->getConceptTag();
368 return getConceptDescriptorOrReapplyQueue(conTag,conDes,depTrackPoint,reapplyQueue);
369 }
370
371
372 bool CReapplyConceptLabelSet::getConceptDescriptorOrReapplyQueue(cint64 conTag, CConceptDescriptor*& conDes, CDependencyTrackPoint*& depTrackPoint, CCondensedReapplyQueue*& reapplyQueue) {
373 CConceptDescriptorDependencyReapplyData* conDesDepData = nullptr;
374 bool contained = mConceptDesDepMap.tryGetValuePointer(conTag,conDesDepData);
375 if (!conDesDepData && mAdditionalConceptDesDepMap) {
376 contained = mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,conDesDepData);
377 }
378 if (contained) {
379 conDes = conDesDepData->mConceptDescriptor;
380 reapplyQueue = &conDesDepData->mPosNegReapplyQueue;
381 if (conDes) {
382 depTrackPoint = conDes->getDependencyTrackPoint();
383 } else {
384 depTrackPoint = nullptr;
385 }
386 contained = conDes != nullptr || reapplyQueue != nullptr;
387 }
388 return contained;
389 }
390
391
392 CCondensedReapplyQueue* CReapplyConceptLabelSet::getConceptDescriptorAndReapplyQueue(CConcept*& concept, CConceptDescriptor*& conDes, bool create) {
393 cint64 conTag = concept->getConceptTag();
394 if (create) {
395 bool containsAlready = false;
396 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
397 mConceptDesDepMap.tryInsert(conTag,CConceptDescriptorDependencyReapplyData(nullptr),&containsAlready,&containedConDesDepData);
398 if (!containsAlready && mAdditionalConceptDesDepMap) {
399 const CConceptDescriptorDependencyReapplyData& addConDesDepData = mAdditionalConceptDesDepMap->value(conTag);
400 if (addConDesDepData.mConceptDescriptor || !addConDesDepData.mPosNegReapplyQueue.isEmpty()) {
401 *containedConDesDepData = addConDesDepData;
402 containsAlready = true;
403 }
404 }
405 conDes = containedConDesDepData->mConceptDescriptor;
406 return &containedConDesDepData->mPosNegReapplyQueue;
407 } else {
408 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
409 if (mConceptDesDepMap.tryGetValuePointer(conTag,containedConDesDepData)) {
410 conDes = containedConDesDepData->mConceptDescriptor;
411 return &containedConDesDepData->mPosNegReapplyQueue;
412 } else if (mAdditionalConceptDesDepMap && mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,containedConDesDepData)) {
413 conDes = containedConDesDepData->mConceptDescriptor;
414 return &containedConDesDepData->mPosNegReapplyQueue;
415 }
416 }
417 return nullptr;
418 }
419
420
421
422 CCondensedReapplyQueue* CReapplyConceptLabelSet::getConceptReapplyQueue(cint64 conTag, bool create) {
423 if (create) {
424 bool containsAlready = false;
425 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
426 mConceptDesDepMap.tryInsert(conTag,CConceptDescriptorDependencyReapplyData(nullptr),&containsAlready,&containedConDesDepData);
427 if (!containsAlready && mAdditionalConceptDesDepMap) {
428 const CConceptDescriptorDependencyReapplyData& addConDesDepData = mAdditionalConceptDesDepMap->value(conTag);
429 if (addConDesDepData.mConceptDescriptor || !addConDesDepData.mPosNegReapplyQueue.isEmpty()) {
430 *containedConDesDepData = addConDesDepData;
431 containsAlready = true;
432 }
433 }
434 return &containedConDesDepData->mPosNegReapplyQueue;
435 //if (conceptNegation) {
436 // return &containedConDesDepData->mNegReapplyQueue;
437 //} else {
438 // return &containedConDesDepData->mPosReapplyQueue;
439 //}
440 } else {
441 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
442 if (mConceptDesDepMap.tryGetValuePointer(conTag,containedConDesDepData)) {
443 return &containedConDesDepData->mPosNegReapplyQueue;
444 //if (conceptNegation) {
445 // return &containedConDesDepData->mNegReapplyQueue;
446 //} else {
447 // return &containedConDesDepData->mPosReapplyQueue;
448 //}
449 } else if (mAdditionalConceptDesDepMap && mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,containedConDesDepData)) {
450 return &containedConDesDepData->mPosNegReapplyQueue;
451 }
452 }
453 return nullptr;
454 }
455
456
457
458 CCondensedReapplyQueue* CReapplyConceptLabelSet::getConceptReapplyQueue(CConcept *&concept, bool &conceptNegation, bool create) {
459 cint64 conTag = concept->getConceptTag();
460 return getConceptReapplyQueue(conTag,create);
461 }
462
463
464 bool CReapplyConceptLabelSet::containsConceptReapplyQueue(CConcept *&concept, bool &conceptNegation) {
465 cint64 conTag = concept->getConceptTag();
466 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
467 if (mConceptDesDepMap.tryGetValuePointer(conTag,containedConDesDepData)) {
468 return !containedConDesDepData->mPosNegReapplyQueue.isEmpty();
469 //if (conceptNegation) {
470 // return !containedConDesDepData->mNegReapplyQueue.isEmpty();
471 //} else {
472 // return !containedConDesDepData->mPosReapplyQueue.isEmpty();
473 //}
474 } else if (mAdditionalConceptDesDepMap && mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,containedConDesDepData)) {
475 return !containedConDesDepData->mPosNegReapplyQueue.isEmpty();
476 }
477 return false;
478 }
479
480 CCondensedReapplyQueueIterator CReapplyConceptLabelSet::getConceptReapplyIterator(CConcept* concept, bool conceptNegation, bool clearDynamicReapplyQueue) {
481 cint64 conTag = concept->getConceptTag();
482 CConceptDescriptorDependencyReapplyData* containedConDesDepData = nullptr;
483 if (mConceptDesDepMap.tryGetValuePointer(conTag,containedConDesDepData)) {
484 if (!clearDynamicReapplyQueue) {
485 return containedConDesDepData->mPosNegReapplyQueue.getIterator(conceptNegation, false);
486 } else {
487 CConceptDescriptorDependencyReapplyData& conDesDepData = mConceptDesDepMap[conTag];
488 return conDesDepData.mPosNegReapplyQueue.getIterator(conceptNegation, true);
489 }
490 //if (conceptNegation) {
491 // return containedConDesDepData->mNegReapplyQueue.getIterator(clearDynamicReapplyQueue);
492 //} else {
493 // return containedConDesDepData->mPosReapplyQueue.getIterator(clearDynamicReapplyQueue);
494 //}
495 } else if (mAdditionalConceptDesDepMap && mAdditionalConceptDesDepMap->tryGetValuePointer(conTag,containedConDesDepData)) {
496 if (!clearDynamicReapplyQueue) {
497 return containedConDesDepData->mPosNegReapplyQueue.getIterator(conceptNegation, false);
498 } else {
499 if (!containedConDesDepData->mPosNegReapplyQueue.isEmpty()) {
500 CConceptDescriptorDependencyReapplyData& conDesDepData = mConceptDesDepMap[conTag];
501 conDesDepData = *containedConDesDepData;
502 return conDesDepData.mPosNegReapplyQueue.getIterator(conceptNegation, true);
503 } else {
504 return containedConDesDepData->mPosNegReapplyQueue.getIterator(conceptNegation, false);
505 }
506 }
507 }
508 return CCondensedReapplyQueueIterator(nullptr,conceptNegation);
509 }
510
511 CCondensedReapplyQueueIterator CReapplyConceptLabelSet::getConceptReapplyIterator(CConceptDescriptor* conDes, bool clearDynamicReapplyQueue) {
512 return getConceptReapplyIterator(conDes->getConcept(),conDes->isNegated(),clearDynamicReapplyQueue);
513 }
514
515
516 CConceptDescriptor* CReapplyConceptLabelSet::getAddingSortedConceptDescriptionLinker() {
517 return mConceptDesLinker;
518 }
519
520
521 CConceptDescriptorDependencyReapplyData* CReapplyConceptLabelSet::getConceptDescriptorDependencyReapplyData(cint64 dataTag) {
522 CConceptDescriptorDependencyReapplyData& conData = mConceptDesDepMap[dataTag];
523 if (mAdditionalConceptDesDepMap && !conData.mConceptDescriptor && conData.mPosNegReapplyQueue.isEmpty()) {
524 const CConceptDescriptorDependencyReapplyData& addConDesDepData = mAdditionalConceptDesDepMap->value(dataTag);
525 conData = addConDesDepData;
526 }
527 return &conData;
528 }
529
530
531 }; // end namespace Process
532
533 }; // end namespace Kernel
534
535 }; // end namespace Reasoner
536
537 }; // end namespace Konclude