| 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 "CCondensedReapplyQueue.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Kernel { |
| 29 |
|
| 30 |
namespace Process { |
| 31 |
|
| 32 |
|
| 33 |
CCondensedReapplyQueue::CCondensedReapplyQueue() { |
| 34 |
mDynamicPosNegReapplyDesLinker = nullptr; |
| 35 |
#ifdef KONCLUDE_EMPLOY_REASONER_KERNEL_PROCESS_CONDENSED_REAPPLY_QUEUE_COUNT |
| 36 |
mDynamicPosNegCount = 0; |
| 37 |
#endif |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
CCondensedReapplyQueue* CCondensedReapplyQueue::initReapplyQueue(CCondensedReapplyQueue* prevReapplyQueue) { |
| 42 |
if (prevReapplyQueue) { |
| 43 |
mDynamicPosNegReapplyDesLinker = prevReapplyQueue->mDynamicPosNegReapplyDesLinker; |
| 44 |
#ifdef KONCLUDE_EMPLOY_REASONER_KERNEL_PROCESS_CONDENSED_REAPPLY_QUEUE_COUNT |
| 45 |
mDynamicPosNegCount = prevReapplyQueue->mDynamicPosNegCount; |
| 46 |
#endif |
| 47 |
} else { |
| 48 |
mDynamicPosNegReapplyDesLinker = nullptr; |
| 49 |
#ifdef KONCLUDE_EMPLOY_REASONER_KERNEL_PROCESS_CONDENSED_REAPPLY_QUEUE_COUNT |
| 50 |
mDynamicPosNegCount = 0; |
| 51 |
#endif |
| 52 |
} |
| 53 |
return this; |
| 54 |
} |
| 55 |
|
| 56 |
#ifdef KONCLUDE_EMPLOY_REASONER_KERNEL_PROCESS_CONDENSED_REAPPLY_QUEUE_COUNT |
| 57 |
qint64 CCondensedReapplyQueue::getReapplyCount() { |
| 58 |
return mDynamicPosNegCount; |
| 59 |
} |
| 60 |
#endif |
| 61 |
|
| 62 |
bool CCondensedReapplyQueue::isEmpty() const { |
| 63 |
return !mDynamicPosNegReapplyDesLinker; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
bool CCondensedReapplyQueue::hasConceptDescriptor(CConceptDescriptor* conceptDescriptor) { |
| 68 |
CCondensedReapplyConceptDescriptor* desLinker = mDynamicPosNegReapplyDesLinker; |
| 69 |
while (desLinker) { |
| 70 |
if (desLinker->hasConceptDescriptor(conceptDescriptor)) { |
| 71 |
return true; |
| 72 |
} |
| 73 |
desLinker = desLinker->getNext(); |
| 74 |
} |
| 75 |
return false; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
CCondensedReapplyQueue* CCondensedReapplyQueue::addReapplyConceptDescriptor(CCondensedReapplyConceptDescriptor *conProDes) { |
| 80 |
if (conProDes) { |
| 81 |
mDynamicPosNegReapplyDesLinker = (CCondensedReapplyConceptDescriptor*)conProDes->append(mDynamicPosNegReapplyDesLinker); |
| 82 |
#ifdef KONCLUDE_EMPLOY_REASONER_KERNEL_PROCESS_CONDENSED_REAPPLY_QUEUE_COUNT |
| 83 |
++mDynamicPosNegCount; |
| 84 |
#endif |
| 85 |
} |
| 86 |
return this; |
| 87 |
} |
| 88 |
|
| 89 |
CCondensedReapplyQueueIterator CCondensedReapplyQueue::getIterator(bool onlyPositiveDescriptors, bool clearDynamicReapplyQueue) { |
| 90 |
return getIterator(onlyPositiveDescriptors == true,onlyPositiveDescriptors == false,clearDynamicReapplyQueue); |
| 91 |
} |
| 92 |
|
| 93 |
CCondensedReapplyQueueIterator CCondensedReapplyQueue::getIterator(bool positiveDescriptors, bool negativeDescriptors, bool clearDynamicReapplyQueue) { |
| 94 |
CCondensedReapplyQueueIterator it(mDynamicPosNegReapplyDesLinker,positiveDescriptors,negativeDescriptors); |
| 95 |
if (clearDynamicReapplyQueue) { |
| 96 |
mDynamicPosNegReapplyDesLinker = nullptr; |
| 97 |
#ifdef KONCLUDE_EMPLOY_REASONER_KERNEL_PROCESS_CONDENSED_REAPPLY_QUEUE_COUNT |
| 98 |
mDynamicPosNegCount = 0; |
| 99 |
#endif |
| 100 |
} |
| 101 |
return it; |
| 102 |
} |
| 103 |
|
| 104 |
}; // end namespace Process |
| 105 |
|
| 106 |
}; // end namespace Kernel |
| 107 |
|
| 108 |
}; // end namespace Reasoner |
| 109 |
|
| 110 |
}; // end namespace Konclude |