| 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 |
#ifndef KONCLUDE_REASONER_KERNEL_CACHE_CREUSECOMPLETIONGRAPHCACHEREADER_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_CACHE_CREUSECOMPLETIONGRAPHCACHEREADER_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
#include <QAtomicPointer> |
| 26 |
#include <QVector> |
| 27 |
|
| 28 |
// Namespace includes |
| 29 |
#include "CacheSettings.h" |
| 30 |
#include "CReuseCompletionGraphCacheSlotItem.h" |
| 31 |
#include "CReuseCompletionGraphCacheEntry.h" |
| 32 |
|
| 33 |
|
| 34 |
// Other includes |
| 35 |
#include "Utilities/Container/CLinker.h" |
| 36 |
|
| 37 |
#include "Reasoner/Ontology/CConcept.h" |
| 38 |
|
| 39 |
|
| 40 |
// Logger includes |
| 41 |
#include "Logger/CLogger.h" |
| 42 |
|
| 43 |
|
| 44 |
namespace Konclude { |
| 45 |
|
| 46 |
using namespace Utilities::Container; |
| 47 |
|
| 48 |
namespace Reasoner { |
| 49 |
|
| 50 |
using namespace Ontology; |
| 51 |
|
| 52 |
namespace Kernel { |
| 53 |
|
| 54 |
namespace Cache { |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
/*! |
| 59 |
* |
| 60 |
* \class CReuseCompletionGraphCacheReader |
| 61 |
* \author Andreas Steigmiller |
| 62 |
* \version 0.1 |
| 63 |
* \brief TODO |
| 64 |
* |
| 65 |
*/ |
| 66 |
class CReuseCompletionGraphCacheReader : public CLinkerBase<CReuseCompletionGraphCacheReader*,CReuseCompletionGraphCacheReader> { |
| 67 |
// public methods |
| 68 |
public: |
| 69 |
//! Constructor |
| 70 |
CReuseCompletionGraphCacheReader(); |
| 71 |
|
| 72 |
|
| 73 |
CReuseCompletionGraphCacheReader* updateSlot(CReuseCompletionGraphCacheSlotItem* updatedSlot); |
| 74 |
|
| 75 |
CReuseCompletionGraphCacheEntry* getCacheEntry(CConcept* concept, bool* minimalCompletionGraph, bool* deterministicConnection); |
| 76 |
|
| 77 |
|
| 78 |
// protected methods |
| 79 |
protected: |
| 80 |
bool hasUpdatedSlotItem(); |
| 81 |
bool switchToUpdatedSlotItem(); |
| 82 |
|
| 83 |
CXLinker<TConceptNegPair>* getConceptTestLinker(); |
| 84 |
CReuseCompletionGraphCacheReader* releaseConceptTestLinker(CXLinker<TConceptNegPair>* linker); |
| 85 |
|
| 86 |
bool addTestingConcepts(CSortedNegLinker<CConcept*>* conLinker, bool negate, cint64 addingLevel, CCACHINGSET<CConcept*>* testedConceptSet); |
| 87 |
bool addTestingConcept(CConcept* concept, bool negated, cint64 addingLevel, CCACHINGSET<CConcept*>* testedConceptSet); |
| 88 |
|
| 89 |
// protected variables |
| 90 |
protected: |
| 91 |
static const cint64 mTestConceptLinkerVecSize = 4; |
| 92 |
|
| 93 |
|
| 94 |
CReuseCompletionGraphCacheContext mContext; |
| 95 |
CReuseCompletionGraphCacheSlotItem* mCurrentSlot; |
| 96 |
QAtomicPointer<CReuseCompletionGraphCacheSlotItem> mUpdatedSlot; |
| 97 |
|
| 98 |
class CCacheEntryVotingItem { |
| 99 |
public: |
| 100 |
CCacheEntryVotingItem() { |
| 101 |
} |
| 102 |
|
| 103 |
CCacheEntryVotingItem* reset() { |
| 104 |
mIncompatibleCount = 0; |
| 105 |
mEntailedCount = 0; |
| 106 |
mMissingCount = 0; |
| 107 |
mTmpReferenced = false; |
| 108 |
mMinimalFound = false; |
| 109 |
mEntry = nullptr; |
| 110 |
mMinConnectionLevel = mTestConceptLinkerVecSize; |
| 111 |
return this; |
| 112 |
} |
| 113 |
|
| 114 |
cint64 mIncompatibleCount; |
| 115 |
cint64 mEntailedCount; |
| 116 |
cint64 mMissingCount; |
| 117 |
bool mTmpReferenced; |
| 118 |
bool mMinimalFound; |
| 119 |
cint64 mMinConnectionLevel; |
| 120 |
CReuseCompletionGraphCacheEntry* mEntry; |
| 121 |
}; |
| 122 |
|
| 123 |
|
| 124 |
CXLinker<TConceptNegPair>* mFreeLinker; |
| 125 |
QVector<CCacheEntryVotingItem> mEntryVotingVec; |
| 126 |
|
| 127 |
|
| 128 |
CXLinker<TConceptNegPair>* mTestConceptLinkerVec[mTestConceptLinkerVecSize]; |
| 129 |
cint64 mTestConceptLinkerCount; |
| 130 |
cint64 mTestConceptLinkerLevel; |
| 131 |
|
| 132 |
// private methods |
| 133 |
private: |
| 134 |
|
| 135 |
// private variables |
| 136 |
private: |
| 137 |
|
| 138 |
}; |
| 139 |
|
| 140 |
}; // end namespace Cache |
| 141 |
|
| 142 |
}; // end namespace Kernel |
| 143 |
|
| 144 |
}; // end namespace Reasoner |
| 145 |
|
| 146 |
}; // end namespace Konclude |
| 147 |
|
| 148 |
#endif // KONCLUDE_REASONER_KERNEL_CACHE_CREUSECOMPLETIONGRAPHCACHEREADER_H |