| 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 "CIndividualDepthConceptProcessDescriptorProcessingQueue.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CIndividualDepthConceptProcessDescriptorProcessingQueue::CIndividualDepthConceptProcessDescriptorProcessingQueue(CProcessContext* processContext) |
| 34 |
: mProcessContext(processContext),mPriorityIndiDesMap(processContext) { |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
CIndividualDepthConceptProcessDescriptorProcessingQueue* CIndividualDepthConceptProcessDescriptorProcessingQueue::initProcessingQueue(CIndividualDepthConceptProcessDescriptorProcessingQueue* processingQueue) { |
| 39 |
if (processingQueue) { |
| 40 |
mPriorityIndiDesMap = processingQueue->mPriorityIndiDesMap; |
| 41 |
} else { |
| 42 |
mPriorityIndiDesMap.clear(); |
| 43 |
} |
| 44 |
return this; |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
bool CIndividualDepthConceptProcessDescriptorProcessingQueue::takeNextProcessIndiviudalConceptProcessDescriptor(CIndividualProcessNode*& nextNode, CConceptProcessDescriptor*& conProDes) { |
| 49 |
if (!mPriorityIndiDesMap.isEmpty()) { |
| 50 |
CPROCESSMAP<CIndividualDepthPriority,CIndividualDepthConceptProcessDescriptorProcessingQueueData>::iterator it = mPriorityIndiDesMap.begin(); |
| 51 |
nextNode = it.value().mIndiNode; |
| 52 |
conProDes = it.value().mConProDes; |
| 53 |
it = mPriorityIndiDesMap.erase(it); |
| 54 |
return true; |
| 55 |
} |
| 56 |
return false; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
bool CIndividualDepthConceptProcessDescriptorProcessingQueue::getNextProcessIndiviudalConceptProcessDescriptor(CIndividualProcessNode*& nextNode, CConceptProcessDescriptor*& conProDes) { |
| 61 |
if (!mPriorityIndiDesMap.isEmpty()) { |
| 62 |
CPROCESSMAP<CIndividualDepthPriority, CIndividualDepthConceptProcessDescriptorProcessingQueueData>::iterator it = mPriorityIndiDesMap.begin(); |
| 63 |
nextNode = it.value().mIndiNode; |
| 64 |
conProDes = it.value().mConProDes; |
| 65 |
return true; |
| 66 |
} |
| 67 |
return false; |
| 68 |
} |
| 69 |
|
| 70 |
CIndividualDepthConceptProcessDescriptorProcessingQueue* CIndividualDepthConceptProcessDescriptorProcessingQueue::insertProcessIndiviudalConceptProcessDescriptor(CIndividualProcessNode* individual, CConceptProcessDescriptor* conProDes) { |
| 71 |
CIndividualDepthPriority priority(individual->getIndividualNominalLevelOrAncestorDepth(),individual->getIndividualNodeID()); |
| 72 |
if (conProDes->getProcessingRestrictionSpecification()) { |
| 73 |
mPriorityIndiDesMap.insertMulti(priority, CIndividualDepthConceptProcessDescriptorProcessingQueueData(conProDes, individual)); |
| 74 |
} else { |
| 75 |
mPriorityIndiDesMap.insert(priority, CIndividualDepthConceptProcessDescriptorProcessingQueueData(conProDes, individual)); |
| 76 |
} |
| 77 |
return this; |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
CConceptProcessDescriptor* CIndividualDepthConceptProcessDescriptorProcessingQueue::removeQueuedProcessIndiviudal(CIndividualProcessNode* individual) { |
| 82 |
CConceptProcessDescriptor* conProDes = nullptr; |
| 83 |
CIndividualDepthPriority priority(individual->getIndividualNominalLevelOrAncestorDepth(),individual->getIndividualNodeID()); |
| 84 |
CPROCESSMAP<CIndividualDepthPriority, CIndividualDepthConceptProcessDescriptorProcessingQueueData>::iterator it = mPriorityIndiDesMap.find(priority); |
| 85 |
if (it != mPriorityIndiDesMap.end()) { |
| 86 |
conProDes = it.value().mConProDes; |
| 87 |
it = mPriorityIndiDesMap.erase(it); |
| 88 |
} |
| 89 |
return conProDes; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
bool CIndividualDepthConceptProcessDescriptorProcessingQueue::isEmpty() { |
| 95 |
return mPriorityIndiDesMap.count() <= 0; |
| 96 |
} |
| 97 |
|
| 98 |
cint64 CIndividualDepthConceptProcessDescriptorProcessingQueue::getQueuedIndividualCount() { |
| 99 |
return mPriorityIndiDesMap.count(); |
| 100 |
} |
| 101 |
|
| 102 |
bool CIndividualDepthConceptProcessDescriptorProcessingQueue::hasQueuedIndividuals() { |
| 103 |
return mPriorityIndiDesMap.count() > 0; |
| 104 |
} |
| 105 |
|
| 106 |
bool CIndividualDepthConceptProcessDescriptorProcessingQueue::isIndividualQueued(CIndividualProcessNode *individual) { |
| 107 |
CIndividualDepthPriority priority(individual->getIndividualNominalLevelOrAncestorDepth(),individual->getIndividualNodeID()); |
| 108 |
return mPriorityIndiDesMap.contains(priority); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
CPROCESSMAP<CIndividualDepthPriority,CIndividualDepthConceptProcessDescriptorProcessingQueueData>* CIndividualDepthConceptProcessDescriptorProcessingQueue::getIndividualDepthConceptProcessDescriptorProcessingQueue() { |
| 113 |
return &mPriorityIndiDesMap; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
}; // end namespace Process |
| 118 |
|
| 119 |
}; // end namespace Kernel |
| 120 |
|
| 121 |
}; // end namespace Reasoner |
| 122 |
|
| 123 |
}; // end namespace Konclude |