Debian Codegraph @

Source/Reasoner/Kernel/Cache/CBackendRepresentativeMemoryCacheReader.h

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 #ifndef KONCLUDE_REASONER_KERNEL_CACHE_CBACKENDREPRESENTATIVEMEMORYCACHEREADER_H
22 #define KONCLUDE_REASONER_KERNEL_CACHE_CBACKENDREPRESENTATIVEMEMORYCACHEREADER_H
23
24 // Libraries includes
25 #include <QAtomicPointer>
26
27 // Namespace includes
28 #include "CacheSettings.h"
29 #include "CBackendRepresentativeMemoryCacheSlotItem.h"
30 #include "CBackendRepresentativeMemoryLabelSignatureResolveCacheItem.h"
31 #include "CBackendRepresentativeMemoryCacheIndividualAssociationData.h"
32 #include "CBackendRepresentativeMemoryCacheRoleAssertionLinker.h"
33 #include "CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker.h"
34 #include "CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData.h"
35 #include "CBackendRepresentativeMemoryLabelCacheItemIndividualAssociationMapExtensionData.h"
36 #include "CBackendRepresentativeMemoryLabelCacheItemTagLabelResolvingExtensionData.h"
37
38
39 // Other includes
40 #include "Utilities/Container/CLinker.h"
41
42 #include "Reasoner/Kernel/Algorithm/CCalculationErrorProcessingException.h"
43
44 #include "Reasoner/Kernel/Process/CConceptSaturationDescriptor.h"
45 #include "Reasoner/Kernel/Process/CConceptDescriptor.h"
46 #include "Reasoner/Kernel/Process/CIndividualMergingHash.h"
47 #include "Reasoner/Kernel/Process/CDistinctHash.h"
48
49 #include "Reasoner/Ontology/CIndividualProcessData.h"
50 #include "Reasoner/Ontology/CIndividual.h"
51 #include "Reasoner/Ontology/CConcreteOntology.h"
52
53 // Logger includes
54 #include "Logger/CLogger.h"
55
56
57 namespace Konclude {
58
59 using namespace Utilities::Container;
60
61 namespace Reasoner {
62
63 using namespace Ontology;
64
65 namespace Kernel {
66
67 using namespace Process;
68 using namespace Algorithm;
69
70 namespace Cache {
71
72 /*!
73 *
74 * \class CBackendRepresentativeMemoryCacheReader
75 * \author Andreas Steigmiller
76 * \version 0.1
77 * \brief TODO
78 *
79 */
80 class CBackendRepresentativeMemoryCacheReader : public CLinkerBase<CBackendRepresentativeMemoryCacheReader*,CBackendRepresentativeMemoryCacheReader> {
81 // public methods
82 public:
83 //! Constructor
84 CBackendRepresentativeMemoryCacheReader();
85
86
87 CBackendRepresentativeMemoryCacheReader* updateSlot(CBackendRepresentativeMemoryCacheSlotItem* updatedSlot);
88 CBackendRepresentativeMemoryCacheReader* fixOntologyData(CBackendRepresentativeMemoryCacheOntologyData* ontologyData);
89 CBackendRepresentativeMemoryCacheReader* checkRecomputationIdUsage(cint64 recomputationId);
90
91
92 CBackendRepresentativeMemoryCacheReader* setWorkingOntology(cint64 ontologyIdentifier);
93 CBackendRepresentativeMemoryCacheReader* setWorkingOntology(CConcreteOntology* ontology);
94
95
96 bool hasSameIndividualsMergings();
97
98
99 bool hasCacheEntry(cint64 labelType, cint64 signature);
100 CBackendRepresentativeMemoryLabelSignatureResolveCacheItem* getLabelCacheEntry(cint64 labelType, cint64 signature);
101
102 bool visitLabelCacheEntries(cint64 labelType, function<bool(CBackendRepresentativeMemoryLabelCacheItem* labelItem)> visitFunc);
103
104
105 CBackendRepresentativeMemoryLabelCacheItem* getLabelCacheEntryViaProvidedCacheValues(cint64 labelType, cint64 signature, cint64 count, function<bool(bool, cint64&, CCacheValue&)> provFunc);
106 CBackendRepresentativeMemoryLabelCacheItem* getLabelCacheEntryViaRoleLinker(cint64 labelType, cint64 signature, cint64 count, CSortedNegLinker<CRole*>* roleLinker, bool inversed, CRole* assertedRole = nullptr);
107 CBackendRepresentativeMemoryLabelCacheItem* getLabelCacheEntryViaRoleAssertionLinker(cint64 labelType, cint64 signature, cint64 count, CBackendRepresentativeMemoryCacheRoleAssertionLinker* roleAssertionLinker);
108
109
110 CBackendRepresentativeMemoryLabelCacheItem* getNeighbourRoleInstantiatedSetCompinationLabelCacheEntry(cint64 signature, cint64 count, CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinker);
111
112 CBackendRepresentativeMemoryLabelCacheItem* getConceptSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 conCount, CConceptSaturationDescriptor* conDesLinker);
113 CBackendRepresentativeMemoryLabelCacheItem* getDeterministicConceptSetLabelCacheEntry(cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, cint64 maxDeterministicBranchTag, bool excludePositiveNominalConcepts);
114 CBackendRepresentativeMemoryLabelCacheItem* getNondeterministicConceptSetLabelCacheEntry(cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, cint64 maxDeterministicBranchTag, bool excludePositiveNominalConcepts);
115 CBackendRepresentativeMemoryLabelCacheItem* getConceptSetLabelCacheEntry(cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, bool deterministic, cint64 maxDeterministicBranchTag, bool excludePositiveNominalConcepts);
116 CBackendRepresentativeMemoryLabelCacheItem* getConceptSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, function<bool(CConcept* concept, bool negation)> exclusionDetermineFunction);
117 CBackendRepresentativeMemoryLabelCacheItem* getFullConceptSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 conCount, CConceptDescriptor* conDesLinker, function<bool(CConcept* concept, bool negation)> exclusionDetermineFunction, function<bool(CConcept* concept, bool negation, CDependencyTrackPoint* depTrackPoint)> nondeterministicDetermineFunction);
118 CBackendRepresentativeMemoryCacheIndividualAssociationData* getIndividualAssociationData(CIndividual* individual);
119 CBackendRepresentativeMemoryCacheIndividualAssociationData* getIndividualAssociationData(cint64 indiId);
120
121
122 CBackendRepresentativeMemoryLabelCacheItem* getIndividualAssociatedCacheLabelItem(cint64 indiId, cint64 labelType);
123
124
125 CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* getNominalIndirectConnectionData(cint64 indiId);
126
127 CBackendRepresentativeMemoryLabelCacheItem* getIndividualSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 indiId, CDistinctHash* indiDistinctHash, cint64& count, bool onlyDeterministic, cint64 maxDeterministicBranchTag);
128 CBackendRepresentativeMemoryLabelCacheItem* getIndividualSetLabelCacheEntry(cint64 labelType, cint64 signature, cint64 indiId, CIndividualMergingHash* indiMerginghash, cint64& count, bool onlyDeterministic, cint64 maxDeterministicBranchTag);
129 CBackendRepresentativeMemoryLabelCacheItem* getIndividualSetLabelCacheEntry(cint64 labelType, cint64 signature, CPROCESSSET<cint64>* individualSet, cint64& count);
130
131
132
133 const CCacheValue getCacheValue(cint64 indiId, bool negation);
134
135 const CCacheValue getCacheValue(CConcept* concept, bool negation, bool deterministic = true);
136 const CCacheValue getCacheValue(CRole* role);
137 const CCacheValue getCacheValue(CRole* role, bool inversed, bool assertionLinkBase = false, bool nominalLinkBase = false, bool nondeterministic = false);
138 const CCacheValue getCacheValue(CBackendRepresentativeMemoryCacheTemporaryLabelReferenceDataLinker* neigbourRoleInstantiatedSetTmpLabelLinker);
139
140
141 bool isCacheValueRoleInverse(const CCacheValue& cacheValue);
142 bool isCacheValueRoleNondeterministic(const CCacheValue& cacheValue);
143 bool isCacheValueRoleNominal(const CCacheValue& cacheValue);
144 bool isCacheValueRoleAssertion(const CCacheValue& cacheValue);
145
146
147 bool visitNominalIndirectlyConnectedIndividualIds(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryCacheNominalIndividualIndirectConnectionData* nomConnData, function<bool(cint64 indiId)> visitFunc);
148 bool visitIndividualIdsOfAssociatedIndividualSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* indiSetLabel, function<bool(cint64 indiId)> visitFunc);
149
150 bool hasIndividualIdsInAssociatedIndividualSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* indiSetLabel, cint64 indiId);
151
152
153 bool visitConceptsOfAssociatedDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, function<bool(CConcept*, bool)> visitFunc);
154 bool hasConceptInAssociatedDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CConcept* concept, bool negation);
155
156 bool visitConceptsOfAssociatedNonDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, function<bool(CConcept*, bool)> visitFunc);
157 bool hasConceptInAssociatedNonDeterministicConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CConcept* concept, bool negation);
158
159 bool visitConceptsOfAssociatedConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept*, bool)> visitFunc);
160 bool hasConceptInAssociatedConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation);
161
162 bool visitConceptsOfFullConceptSetLabel(CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept* concept, bool negation, bool deterministic)> visitFunc, bool visitDeterministicConcepts, bool visitNonDeterministicConcepts);
163 bool visitConceptsOfAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(CConcept* concept, bool negation, bool deterministic)> visitFunc, bool visitDeterministicConcepts = true, bool visitNonDeterministicConcepts = true);
164 bool hasConceptInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation);
165 bool hasConceptInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool negation, bool deterministic);
166
167 bool getConceptOccurrenceInAssociatedFullConceptSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* labelItem, CConcept* concept, bool& negationFlag, bool& deterministicFlag);
168
169
170
171 bool visitNeighbourIndividualIdsForNeighbourArrayIdFromCursor(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 arrayId, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic, cint64 nextCursor)> visitFunc, bool visitOnlyDeterministicNeighbours = true, cint64 cursor = 0);
172 bool visitNeighbourIndividualIdsForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic)> visitFunc, bool visitOnlyDeterministicNeighbours = true);
173 bool visitNeighbourArrayIdsForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role, function<bool(cint64 neighbourIndividualId, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, bool nondeterministic)> visitFunc, bool visitOnlyDeterministicNeighbours = true);
174
175 cint64 getNeighbourCountForRole(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CRole* role);
176 cint64 getNeighbourCountForArrayPos(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 pos);
177
178
179 bool visitRolesOfAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, function<bool(CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)> visitFunc);
180 bool hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic);
181 bool hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed);
182 bool hasRoleInAssociatedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed, bool nondeterministic);
183
184 bool hasRoleInAssociatedCombinedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, CRole* role, bool inversed);
185
186
187 bool visitLabelsOfAssociatedNeigbourRoleSetCombinationLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetCompinationLabel, function<bool(CBackendRepresentativeMemoryLabelCacheItem* label)> visitFunc);
188
189
190 bool visitRolesOfAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* combinationRoleSetLabel, function<bool(CRole* role, bool inversed)> visitFunc);
191 bool hasRoleInAssociatedCompinationRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* compinationRoleSetLabel, CRole* role, bool inversed);
192
193 bool visitRolesOfAssociatedCombinedNeigbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, CBackendRepresentativeMemoryLabelCacheItem* neighbourRoleSetLabel, function<bool(CRole* role, bool inversed)> visitFunc);
194
195 bool hasRoleToNeigbourInAssociatedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 neighbourIndiId, CRole* role, bool inversed);
196 bool visitRolesToNeigbourInAssociatedNeighbourRoleSetLabel(CBackendRepresentativeMemoryCacheIndividualAssociationData* assData, cint64 neighbourIndiId, function<bool(CRole* role, bool inversed, bool assertionLinkBase, bool nominalLinkBase, bool nondeterministic)> visitFunc);
197
198
199 bool visitLabelItemIndividualIdAssociations(CBackendRepresentativeMemoryLabelCacheItem* labelItem, function<bool(cint64 indiId, bool sameIndividualMerged)> visitFunc, bool ascending = true, bool visitBaseIndividual = true, bool visitSameMergedIndividuals = true);
200
201
202 // protected methods
203 protected:
204 bool hasUpdatedSlotItem();
205 bool switchToUpdatedSlotItem();
206
207 // protected variables
208 protected:
209 CBackendRepresentativeMemoryCacheSlotItem* mCurrentSlot;
210 QAtomicPointer<CBackendRepresentativeMemoryCacheSlotItem> mUpdatedSlot;
211
212 CBackendRepresentativeMemoryLabelSignatureResolveCacheItem mEmptySigResCacheItem;
213 CBackendRepresentativeMemoryCardinalitySignatureResolveCacheItem mEmptyCardSigResCacheItem;
214
215 cint64 mOntologyIdentifier;
216 cint64 mRecomputationId;
217 CBackendRepresentativeMemoryCacheOntologyData* mOntologyData;
218 CBackendRepresentativeMemoryCacheOntologyData* mFixedOntologyData;
219
220
221 // private methods
222 private:
223
224 // private variables
225 private:
226
227 };
228
229 }; // end namespace Cache
230
231 }; // end namespace Kernel
232
233 }; // end namespace Reasoner
234
235 }; // end namespace Konclude
236
237 #endif // KONCLUDE_REASONER_KERNEL_CACHE_CBACKENDREPRESENTATIVEMEMORYCACHEREADER_H