| 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 "COptimizedRepresentativeKPSetOntologyRealizingItem.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Realizer { |
| 29 |
|
| 30 |
|
| 31 |
COptimizedRepresentativeKPSetOntologyRealizingItem::COptimizedRepresentativeKPSetOntologyRealizingItem() { |
| 32 |
} |
| 33 |
|
| 34 |
COptimizedRepresentativeKPSetOntologyRealizingItem::~COptimizedRepresentativeKPSetOntologyRealizingItem() { |
| 35 |
delete mCalculationConfig; |
| 36 |
delete mInitRealizeProcessingStep; |
| 37 |
delete mRealizeConceptProcessingStep; |
| 38 |
delete mRealizeRoleProcessingStep; |
| 39 |
if (mTempRoleRealizationOntology != mOntology) { |
| 40 |
mTempRoleRealizationOntology->setConsistence(nullptr); |
| 41 |
delete mTempRoleRealizationOntology; |
| 42 |
} |
| 43 |
if (mTempSameRealizationOntology != mOntology) { |
| 44 |
mTempSameRealizationOntology->setConsistence(nullptr); |
| 45 |
delete mTempSameRealizationOntology; |
| 46 |
} |
| 47 |
if (mPossAssCollSet) { |
| 48 |
delete mPossAssCollSet; |
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::initRequirementConfigRealizingItem(CConcreteOntology* ontology, CConfigurationBase* config, CBackendRepresentativeMemoryCacheReader* backendAssocCacheReader) { |
| 54 |
COntologyRealizingItem::initRealizingItem(ontology,config); |
| 55 |
mBackendAssocCacheReader = backendAssocCacheReader; |
| 56 |
mSameMergedIndisInCache = mBackendAssocCacheReader->hasSameIndividualsMergings(); |
| 57 |
mRealization = nullptr; |
| 58 |
mCalculationConfig = new CCalculationConfigurationExtension(config,0); |
| 59 |
COntologyProcessingStepDataVector* ontProStepDataVec = mOntology->getProcessingSteps()->getOntologyProcessingStepDataVector(); |
| 60 |
mInitRealizeProcessingStep = new CRealizingTestingStep(CRealizingTestingStep::INITREALIZEPROCESSINGSTEP, ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSINITREALIZE), this); |
| 61 |
mProcessingSteps.append(mInitRealizeProcessingStep); |
| 62 |
mRealizeConceptProcessingStep = new CRealizingTestingStep(CRealizingTestingStep::REALIZECONCEPTPROCESSINGSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSCONCEPTREALIZE),this); |
| 63 |
mProcessingSteps.append(mRealizeConceptProcessingStep); |
| 64 |
mRealizeRoleProcessingStep = new CRealizingTestingStep(CRealizingTestingStep::REALIZEROLEPROCESSINGSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSROLEREALIZE),this); |
| 65 |
mProcessingSteps.append(mRealizeRoleProcessingStep); |
| 66 |
mRealizeSameIndividualsProcessingStep = new CRealizingTestingStep(CRealizingTestingStep::REALIZESAMEINDIVIDUALSPROCESSINGSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSSAMEINDIVIDUALSREALIZE),this); |
| 67 |
mProcessingSteps.append(mRealizeSameIndividualsProcessingStep); |
| 68 |
mItemsInitialized = false; |
| 69 |
mRealizationSameIndividualsInitialized = false; |
| 70 |
mRealizationConceptsInitialized = false; |
| 71 |
mTestedPossibleConceptInstancesCount = 0; |
| 72 |
mOpenPossibleConceptInstancesCount = 0; |
| 73 |
mTestedPossibleSameIndividualsCount = 0; |
| 74 |
mOpenPossibleSameIndividualsCount = 0; |
| 75 |
mTopConceptInstancesItem = nullptr; |
| 76 |
mBottomConceptInstancesItem = nullptr; |
| 77 |
mTestingPossibleSameIndividualCount = 0; |
| 78 |
mTestingPossibleConceptInstanceCount = 0; |
| 79 |
mTestingPossibleRoleInstanceCount = 0; |
| 80 |
mPropagatingRoleInstanceCandidateCount = 0; |
| 81 |
mTestedPossibleRoleInstancesCount = 0; |
| 82 |
mOpenPossibleRoleInstancesCount = 0; |
| 83 |
mInitializedRoleInstancesCount = 0; |
| 84 |
mRemainingInitalizingRoleInstancesCount = 0; |
| 85 |
mTestingRoleInstanceCandidateCount = 0; |
| 86 |
mTopRoleInstancesItem = nullptr; |
| 87 |
mBottomRoleInstancesItem = nullptr; |
| 88 |
mRealizationRolesInitialized = false; |
| 89 |
mTempRoleRealizationOntology = nullptr; |
| 90 |
mTempSameRealizationOntology = nullptr; |
| 91 |
mRoleRealizationInstalled = false; |
| 92 |
mConceptRealizationInstalled = false; |
| 93 |
mSameRealizationInstalled = false; |
| 94 |
mAllSameIndividualsProcessing = false; |
| 95 |
mAllRoleInstancesProcessing = false; |
| 96 |
mAllConceptInstancesProcessing = false; |
| 97 |
|
| 98 |
mProvidedPossibleInstancesMergingIndividualsCount = 0; |
| 99 |
mProvidedPossibleInstancesMergingsCount = 0; |
| 100 |
mAttemptedPossibleInstancesMergingsCount = 0; |
| 101 |
mSucceddedPossibleInstancesMergingsCount = 0; |
| 102 |
|
| 103 |
mModelMergingsTriedCount = 0; |
| 104 |
mModelMergingsSucessCount = 0; |
| 105 |
mModelMergingsInstanceFoundCount = 0; |
| 106 |
mModelMergingsNonInstanceFoundCount = 0; |
| 107 |
|
| 108 |
mCountingPossibleConceptInstancesTesting = false; |
| 109 |
mCountingPossibleRoleInstancesTesting = false; |
| 110 |
mCountingPossibleSameInstancesTesting = false; |
| 111 |
|
| 112 |
mExtraConsistencyTestingRequired = false; |
| 113 |
mExtraConsistencyTesting = false; |
| 114 |
mExtraConsistencyTested = false; |
| 115 |
|
| 116 |
mPotentiallySameIndividuals = false; |
| 117 |
mIteratorNothingToDoWarning = false; |
| 118 |
|
| 119 |
mIndiDepTrackReq = false; |
| 120 |
if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Realization.IndividualDependenceTracking",true)) { |
| 121 |
mIndiDepTrackReq = true; |
| 122 |
} |
| 123 |
|
| 124 |
mPossAssCollSet = nullptr; |
| 125 |
if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Realization.PossibleAssertionsCollecting",false)) { |
| 126 |
mPossAssCollSet = new CPossibleAssertionsCollectionSet(); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
if (CConfigDataReader::readConfigBoolean(config,"Konclude.Calculation.Realization.ExtraConsistencyTesting",false)) { |
| 131 |
mExtraConsistencyTestingRequired = true; |
| 132 |
} |
| 133 |
|
| 134 |
mConfConcurrentHandlingVectorSize = CConfigDataReader::readConfigInteger(config, "Konclude.Calculation.Realization.ConccurrentItemInitializationVectorSize", 200); |
| 135 |
mIndividualInstantiatedItemHash = new COptimizedKPSetIndividualInstantiatedItemMultiHash(mConfConcurrentHandlingVectorSize); |
| 136 |
|
| 137 |
mInitTime.start(); |
| 138 |
|
| 139 |
return this; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getConcurrentHandlingVectorSize() { |
| 145 |
return mConfConcurrentHandlingVectorSize; |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
CPossibleAssertionsCollectionSet* COptimizedRepresentativeKPSetOntologyRealizingItem::getPossibleAssertionCollectionSet() { |
| 151 |
return mPossAssCollSet; |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::initConceptItemsFromHierarchy() { |
| 156 |
CClassification* classification = mOntology->getClassification(); |
| 157 |
if (classification->hasClassConceptClassification()) { |
| 158 |
CClassConceptClassification* classConClass = classification->getClassConceptClassification(); |
| 159 |
if (classConClass) { |
| 160 |
CTaxonomy* taxonomy = classConClass->getClassConceptTaxonomy(); |
| 161 |
if (taxonomy) { |
| 162 |
QHash<CConcept*,CHierarchyNode*>* conHierNodeHash = taxonomy->getConceptHierarchyNodeHash(); |
| 163 |
for (QHash<CConcept*,CHierarchyNode*>::const_iterator it = conHierNodeHash->constBegin(), itEnd = conHierNodeHash->constEnd(); it != itEnd; ++it) { |
| 164 |
CConcept* concept(it.key()); |
| 165 |
CHierarchyNode* hierNode(it.value()); |
| 166 |
|
| 167 |
COptimizedKPSetConceptInstancesItem* instancesItem = mHierNodeInstancesItemHash.value(hierNode,nullptr); |
| 168 |
if (!instancesItem) { |
| 169 |
instancesItem = new COptimizedKPSetConceptInstancesItem(); |
| 170 |
mConceptInstancesItemContainer.append(instancesItem); |
| 171 |
mHierNodeInstancesItemHash.insert(hierNode,instancesItem); |
| 172 |
instancesItem->initInstancesItem(hierNode); |
| 173 |
} |
| 174 |
mConceptInstancesItemHash.insert(concept,instancesItem); |
| 175 |
} |
| 176 |
|
| 177 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = mConceptInstancesItemContainer.constBegin(), itEnd = mConceptInstancesItemContainer.constEnd(); it != itEnd; ++it) { |
| 178 |
COptimizedKPSetConceptInstancesItem* item(*it); |
| 179 |
CHierarchyNode* node = item->getHierarchyNode(); |
| 180 |
QSet<CHierarchyNode*>* parentNodeSet = node->getParentNodeSet(); |
| 181 |
if (parentNodeSet) { |
| 182 |
for (QSet<CHierarchyNode*>::const_iterator parentIt = parentNodeSet->constBegin(), parentItEnd = parentNodeSet->constEnd(); parentIt != parentItEnd; ++parentIt) { |
| 183 |
CHierarchyNode* parentHierNode(*parentIt); |
| 184 |
COptimizedKPSetConceptInstancesItem* parentItem = mHierNodeInstancesItemHash.value(parentHierNode); |
| 185 |
item->addParentItem(parentItem); |
| 186 |
parentItem->addSuccessorItem(item); |
| 187 |
} |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = mConceptInstancesItemContainer.constBegin(), itEnd = mConceptInstancesItemContainer.constEnd(); it != itEnd; ++it) { |
| 192 |
COptimizedKPSetConceptInstancesItem* item(*it); |
| 193 |
item->setInitialUnprocessedSuccessorItemCount(); |
| 194 |
if (item->getUnprocessedSuccessorItemCount() <= 0) { |
| 195 |
item->setAllSuccessorProcessedFlag(true); |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
mTopConceptInstancesItem = mHierNodeInstancesItemHash.value(taxonomy->getTopHierarchyNode()); |
| 200 |
mBottomConceptInstancesItem = mHierNodeInstancesItemHash.value(taxonomy->getBottomHierarchyNode()); |
| 201 |
|
| 202 |
} |
| 203 |
} |
| 204 |
} |
| 205 |
return this; |
| 206 |
} |
| 207 |
|
| 208 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::initRoleCandidateInitializingIndividualItems() { |
| 209 |
for (QList<COptimizedKPSetIndividualItem*>::const_iterator it = mInstantiatedItemContainer.constBegin(), itEnd = mInstantiatedItemContainer.constEnd(); it != itEnd; ++it) { |
| 210 |
COptimizedKPSetIndividualItem* indiItem(*it); |
| 211 |
if (!indiItem->isItemSameIndividualMerged()) { |
| 212 |
addRoleCandidateInitalizingIndividualsItem(indiItem); |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
return this; |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::initComplexRolesStarterCandidates() { |
| 223 |
CRBox* rbox = mOntology->getRBox(); |
| 224 |
CRoleVector* roleVector = rbox->getRoleVector(false); |
| 225 |
CBOXSET<CRole*>* activeRoleSet = rbox->getActivePropertyRoleSet(false); |
| 226 |
|
| 227 |
if (roleVector && activeRoleSet) { |
| 228 |
QHash<CRole*, CRole*> complexRoleStarterCandExpansionHash; |
| 229 |
QSet<QPair<CRole*, CRole*>> complexRoleStarterCandExpansionSet; |
| 230 |
QList<QPair<CRole*, CRole*>> complexRoleStarterCandExpansionList; |
| 231 |
|
| 232 |
QHash<CRole*, CRole*> complexRoleInverseStarterCandExpansionHash; |
| 233 |
QSet<QPair<CRole*, CRole*>> complexRoleInverseStarterCandExpansionSet; |
| 234 |
QList<QPair<CRole*, CRole*>> complexRoleInverseStarterCandExpansionList; |
| 235 |
|
| 236 |
for (CBOXSET<CRole*>::const_iterator roleIt = activeRoleSet->constBegin(), roleItEnd = activeRoleSet->constEnd(); roleIt != roleItEnd; ++roleIt) { |
| 237 |
CRole* role(*roleIt); |
| 238 |
if (!role->isDataRole() && role->isComplexRole()) { |
| 239 |
for (CXLinker<CRoleChain*>* chainLinkerIt = role->getRoleChainSuperSharingLinker(); chainLinkerIt; chainLinkerIt = chainLinkerIt->getNext()) { |
| 240 |
CRoleChain* roleChain = chainLinkerIt->getData(); |
| 241 |
CRole* firstRole = roleChain->getRoleChainLinker()->getData(); |
| 242 |
|
| 243 |
bool onlyTransitiveComplexRoleCandidates = true; |
| 244 |
for (CXLinker<CRole*>* roleChainLinkerIt = roleChain->getRoleChainLinker(); roleChainLinkerIt && onlyTransitiveComplexRoleCandidates; roleChainLinkerIt = roleChainLinkerIt->getNext()) { |
| 245 |
CRole* chainedRole = roleChainLinkerIt->getData(); |
| 246 |
if (chainedRole != role) { |
| 247 |
onlyTransitiveComplexRoleCandidates = false; |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
CRole* firstInverseRole = nullptr; |
| 252 |
if (roleChain->getInverseRoleChainLinker()) { |
| 253 |
firstInverseRole = roleChain->getInverseRoleChainLinker()->getData()->getInverseRole(); |
| 254 |
} |
| 255 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 256 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 257 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 258 |
bool itemInversed = redRoleItem->isInversed(); |
| 259 |
|
| 260 |
for (CSortedNegLinker<CRole*>* indSuperRoleLinker = role->getIndirectSuperRoleList(); indSuperRoleLinker; indSuperRoleLinker = indSuperRoleLinker->getNext()) { |
| 261 |
CRole* superRole = indSuperRoleLinker->getData(); |
| 262 |
bool superRoleInversed = indSuperRoleLinker->isNegated(); |
| 263 |
|
| 264 |
if (!superRoleInversed) { |
| 265 |
if (!complexRoleStarterCandExpansionSet.contains(QPair<CRole*, CRole*>(superRole, firstRole))) { |
| 266 |
complexRoleStarterCandExpansionSet.insert(QPair<CRole*, CRole*>(superRole, firstRole)); |
| 267 |
complexRoleStarterCandExpansionHash.insertMulti(superRole, firstRole); |
| 268 |
} |
| 269 |
if (superRole->isComplexRole()) { |
| 270 |
complexRoleStarterCandExpansionList.append(QPair<CRole*, CRole*>(superRole, firstRole)); |
| 271 |
} |
| 272 |
} else { |
| 273 |
if (!complexRoleInverseStarterCandExpansionSet.contains(QPair<CRole*, CRole*>(superRole, firstRole))) { |
| 274 |
complexRoleInverseStarterCandExpansionSet.insert(QPair<CRole*, CRole*>(superRole, firstRole)); |
| 275 |
complexRoleInverseStarterCandExpansionHash.insertMulti(superRole, firstRole); |
| 276 |
} |
| 277 |
if (superRole->isComplexRole()) { |
| 278 |
complexRoleInverseStarterCandExpansionList.append(QPair<CRole*, CRole*>(superRole, firstRole)); |
| 279 |
} |
| 280 |
} |
| 281 |
if (firstInverseRole) { |
| 282 |
if (!superRoleInversed) { |
| 283 |
if (!complexRoleInverseStarterCandExpansionSet.contains(QPair<CRole*, CRole*>(superRole, firstInverseRole))) { |
| 284 |
complexRoleInverseStarterCandExpansionSet.insert(QPair<CRole*, CRole*>(superRole, firstInverseRole)); |
| 285 |
complexRoleInverseStarterCandExpansionHash.insertMulti(superRole, firstInverseRole); |
| 286 |
} |
| 287 |
if (superRole->isComplexRole()) { |
| 288 |
complexRoleInverseStarterCandExpansionList.append(QPair<CRole*, CRole*>(superRole, firstInverseRole)); |
| 289 |
} |
| 290 |
} else { |
| 291 |
if (!complexRoleStarterCandExpansionSet.contains(QPair<CRole*, CRole*>(superRole, firstInverseRole))) { |
| 292 |
complexRoleStarterCandExpansionSet.insert(QPair<CRole*, CRole*>(superRole, firstInverseRole)); |
| 293 |
complexRoleStarterCandExpansionHash.insertMulti(superRole, firstInverseRole); |
| 294 |
} |
| 295 |
if (superRole->isComplexRole()) { |
| 296 |
complexRoleStarterCandExpansionList.append(QPair<CRole*, CRole*>(superRole, firstInverseRole)); |
| 297 |
} |
| 298 |
} |
| 299 |
} |
| 300 |
|
| 301 |
COptimizedKPSetRoleInstancesItem* superRoleItem = mRoleInstancesItemHash.value(superRole); |
| 302 |
if (superRoleItem && superRoleItem != mTopRoleInstancesItem) { |
| 303 |
if (superRoleItem->hasOnlyTransitiveComplexRoleCandidates()) { |
| 304 |
superRoleItem->setOnlyTransitiveComplexRoleCandidates(onlyTransitiveComplexRoleCandidates); |
| 305 |
} |
| 306 |
if (superRoleItem->hasOnlyTransitiveComplexRoleCandidates()) { |
| 307 |
superRoleItem->addOnlyTransitiveComplexSubRoleItem(TRoleItemInversionPair(roleInstItem, superRoleInversed ^ itemInversed)); |
| 308 |
} |
| 309 |
if (superRoleInversed) { |
| 310 |
if (firstInverseRole) { |
| 311 |
superRoleItem->addComplexRoleStarterCandidate(firstInverseRole); |
| 312 |
} |
| 313 |
if (superRoleItem->hasInverseRole()) { |
| 314 |
superRoleItem->addComplexInverseRoleStarterCandidate(firstRole); |
| 315 |
} |
| 316 |
} else { |
| 317 |
superRoleItem->addComplexRoleStarterCandidate(firstRole); |
| 318 |
if (firstInverseRole && superRoleItem->hasInverseRole()) { |
| 319 |
superRoleItem->addComplexInverseRoleStarterCandidate(firstInverseRole); |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
} |
| 324 |
} |
| 325 |
} |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
while (!complexRoleStarterCandExpansionList.isEmpty()) { |
| 330 |
QPair<CRole*, CRole*> roleStarterExpPair = complexRoleStarterCandExpansionList.takeFirst(); |
| 331 |
CRole* superRole = roleStarterExpPair.first; |
| 332 |
|
| 333 |
COptimizedKPSetRoleInstancesItem* superRoleItem = mRoleInstancesItemHash.value(superRole); |
| 334 |
if (superRoleItem && superRoleItem != mTopRoleInstancesItem) { |
| 335 |
CRole* subRole = roleStarterExpPair.second; |
| 336 |
|
| 337 |
QSet<CRole*> subRolesCandidateSet; |
| 338 |
QList<CRole*> subRolesCandidateList(complexRoleStarterCandExpansionHash.values(subRole)); |
| 339 |
for (CRole* role : subRolesCandidateList) { |
| 340 |
subRolesCandidateSet.insert(role); |
| 341 |
} |
| 342 |
|
| 343 |
while (!subRolesCandidateList.isEmpty()) { |
| 344 |
CRole* role = subRolesCandidateList.takeFirst(); |
| 345 |
if (!superRoleItem->hasComplexRoleStarterCandidate(role)) { |
| 346 |
superRoleItem->addComplexRoleStarterCandidate(role); |
| 347 |
|
| 348 |
QList<CRole*> nextSubRolesCandidateList(complexRoleStarterCandExpansionHash.values(role)); |
| 349 |
for (CRole* nextSubRole : nextSubRolesCandidateList) { |
| 350 |
if (!subRolesCandidateSet.contains(role)) { |
| 351 |
subRolesCandidateSet.insert(role); |
| 352 |
subRolesCandidateList.append(nextSubRole); |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
} |
| 357 |
} |
| 358 |
|
| 359 |
} |
| 360 |
|
| 361 |
} |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
while (!complexRoleInverseStarterCandExpansionList.isEmpty()) { |
| 367 |
QPair<CRole*, CRole*> roleStarterExpPair = complexRoleInverseStarterCandExpansionList.takeFirst(); |
| 368 |
CRole* superRole = roleStarterExpPair.first; |
| 369 |
|
| 370 |
COptimizedKPSetRoleInstancesItem* superRoleItem = mRoleInstancesItemHash.value(superRole); |
| 371 |
if (superRoleItem && superRoleItem != mTopRoleInstancesItem) { |
| 372 |
CRole* subRole = roleStarterExpPair.second; |
| 373 |
|
| 374 |
QSet<CRole*> subRolesCandidateSet; |
| 375 |
QList<CRole*> subRolesCandidateList(complexRoleStarterCandExpansionHash.values(subRole)); |
| 376 |
for (CRole* role : subRolesCandidateList) { |
| 377 |
subRolesCandidateSet.insert(role); |
| 378 |
} |
| 379 |
|
| 380 |
while (!subRolesCandidateList.isEmpty()) { |
| 381 |
CRole* role = subRolesCandidateList.takeFirst(); |
| 382 |
if (!superRoleItem->hasComplexInverseRoleStarterCandidate(role)) { |
| 383 |
superRoleItem->addComplexInverseRoleStarterCandidate(role); |
| 384 |
|
| 385 |
QList<CRole*> nextSubRolesCandidateList(complexRoleStarterCandExpansionHash.values(role)); |
| 386 |
for (CRole* nextSubRole : nextSubRolesCandidateList) { |
| 387 |
if (!subRolesCandidateSet.contains(role)) { |
| 388 |
subRolesCandidateSet.insert(role); |
| 389 |
subRolesCandidateList.append(nextSubRole); |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
} |
| 394 |
} |
| 395 |
|
| 396 |
} |
| 397 |
|
| 398 |
} |
| 399 |
|
| 400 |
} |
| 401 |
|
| 402 |
|
| 403 |
for (COptimizedKPSetRoleInstancesItem* complexRoleItem : mComplexRoleInstancesItemContainer) { |
| 404 |
for (CRole* complexStarterCandidateRole : *complexRoleItem->getComplexRoleStarterCandidateSet()) { |
| 405 |
mComplexStarterCandidateRoleInstancesItemHash.insertMulti(complexStarterCandidateRole, complexRoleItem); |
| 406 |
} |
| 407 |
for (CRole* complexInverseStarterCandidateRole : *complexRoleItem->getComplexInverseRoleStarterCandidateSet()) { |
| 408 |
mInverseComplexStarterCandidateRoleInstancesItemHash.insertMulti(complexInverseStarterCandidateRole, complexRoleItem); |
| 409 |
} |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
return this; |
| 414 |
} |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::initRoleItemsFromHierarchy() { |
| 419 |
CClassification* classification = mOntology->getClassification(); |
| 420 |
CPropertyRoleClassification* roleClassification = nullptr; |
| 421 |
if (classification && classification->hasObjectPropertyRoleClassification()) { |
| 422 |
roleClassification = classification->getObjectPropertyRoleClassification(); |
| 423 |
} |
| 424 |
CRolePropertiesHierarchy* roleHierarchy = nullptr; |
| 425 |
if (roleClassification) { |
| 426 |
roleHierarchy = roleClassification->getRolePropertiesHierarchy(); |
| 427 |
} |
| 428 |
CRBox* rbox = mOntology->getRBox(); |
| 429 |
CRoleVector* roleVector = rbox->getRoleVector(false); |
| 430 |
CBOXSET<CRole*>* activeRoleSet = rbox->getActivePropertyRoleSet(false); |
| 431 |
if (roleVector && activeRoleSet) { |
| 432 |
for (CBOXSET<CRole*>::const_iterator roleIt = activeRoleSet->constBegin(), roleItEnd = activeRoleSet->constEnd(); roleIt != roleItEnd; ++roleIt) { |
| 433 |
CRole* role(*roleIt); |
| 434 |
|
| 435 |
//if (role && (CIRIName::getRecentIRIName(role->getPropertyNameLinker()) == "http://ontology.dumontierlab.com/isRelatedTo" || CIRIName::getRecentIRIName(role->getPropertyNameLinker()) == "http://ontology.dumontierlab.com/isTagOf")) { |
| 436 |
// bool debug = true; |
| 437 |
//} |
| 438 |
|
| 439 |
if (!role->isDataRole() && role->hasPropertyName() && !mRedirectedRoleInstancesItemHash.contains(role)) { |
| 440 |
COptimizedKPSetRoleInstancesItem* instancesItem = new COptimizedKPSetRoleInstancesItem(); |
| 441 |
mRoleInstancesItemContainer.append(instancesItem); |
| 442 |
mRoleInstancesItemHash.insert(role,instancesItem); |
| 443 |
COptimizedKPSetRoleInstancesRedirectionItem* roleRedItem = new COptimizedKPSetRoleInstancesRedirectionItem(instancesItem, role, false); |
| 444 |
mRedirectedRoleInstancesItemHash.insert(role, roleRedItem); |
| 445 |
instancesItem->initInstancesItem(role); |
| 446 |
CRole* inverseRole = nullptr; |
| 447 |
|
| 448 |
if (roleHierarchy) { |
| 449 |
|
| 450 |
CRolePropertiesHierarchyNode* invRoleHierNode = nullptr; |
| 451 |
|
| 452 |
CRolePropertiesHierarchyNode* hierNode = roleHierarchy->getHierarchyNode(role); |
| 453 |
instancesItem->setRoleHierarchyNode(hierNode); |
| 454 |
|
| 455 |
typedef QPair<CRole*, bool> TRoleInversionPair; |
| 456 |
QList<TRoleInversionPair> eqInRoleProcessingList; |
| 457 |
QSet<TRoleInversionPair> eqInRoleProcessingSet; |
| 458 |
eqInRoleProcessingList.append(TRoleInversionPair(role, false)); |
| 459 |
eqInRoleProcessingSet.insert(TRoleInversionPair(role, false)); |
| 460 |
|
| 461 |
QList<CRole*>* eqRoleList = hierNode->getEquivalentElementList(); |
| 462 |
for (QList<CRole*>::const_iterator it = eqRoleList->constBegin(), itEnd = eqRoleList->constEnd(); it != itEnd; ++it) { |
| 463 |
CRole* eqRole(*it); |
| 464 |
if (role != eqRole) { |
| 465 |
eqInRoleProcessingList.append(TRoleInversionPair(eqRole, false)); |
| 466 |
eqInRoleProcessingSet.insert(TRoleInversionPair(eqRole, false)); |
| 467 |
} |
| 468 |
} |
| 469 |
|
| 470 |
while (!eqInRoleProcessingList.isEmpty()) { |
| 471 |
TRoleInversionPair procRoleInvPair = eqInRoleProcessingList.takeFirst(); |
| 472 |
CRole* procRole = procRoleInvPair.first; |
| 473 |
bool procRoleInversion = procRoleInvPair.second; |
| 474 |
|
| 475 |
if (procRole != role) { |
| 476 |
COptimizedKPSetRoleInstancesRedirectionItem* invRedirectItem = roleRedItem; |
| 477 |
if (procRole != role) { |
| 478 |
invRedirectItem = new COptimizedKPSetRoleInstancesRedirectionItem(instancesItem, procRole, procRoleInversion); |
| 479 |
mRedirectedRoleInstancesItemHash.insert(procRole, invRedirectItem); |
| 480 |
} |
| 481 |
if (!invRoleHierNode && procRoleInversion) { |
| 482 |
inverseRole = procRole; |
| 483 |
invRoleHierNode = roleHierarchy->getHierarchyNode(inverseRole); |
| 484 |
instancesItem->setInverseRoleHierarchyNode(invRoleHierNode); |
| 485 |
instancesItem->setInverseRoleRedirectedItem(invRedirectItem); |
| 486 |
} |
| 487 |
} else if (!invRoleHierNode && procRoleInversion) { |
| 488 |
inverseRole = procRole; |
| 489 |
instancesItem->setInverseRoleHierarchyNode(hierNode); |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
if (procRole->getInverseRole()) { |
| 494 |
TRoleInversionPair procInverseRoleInvPair(procRole->getInverseRole(), !procRoleInversion); |
| 495 |
if (!eqInRoleProcessingSet.contains(procInverseRoleInvPair)) { |
| 496 |
eqInRoleProcessingSet.insert(procInverseRoleInvPair); |
| 497 |
eqInRoleProcessingList.append(procInverseRoleInvPair); |
| 498 |
} |
| 499 |
} |
| 500 |
for (CSortedNegLinker<CRole*>* eqInvRoleIt = procRole->getInverseEquivalentRoleList(); eqInvRoleIt; eqInvRoleIt = eqInvRoleIt->getNext()) { |
| 501 |
CRole* eqInvRole = eqInvRoleIt->getData(); |
| 502 |
TRoleInversionPair procInverseRoleInvPair(eqInvRole, eqInvRoleIt->isNegated() ^ procRoleInversion); |
| 503 |
if (!eqInRoleProcessingSet.contains(procInverseRoleInvPair)) { |
| 504 |
eqInRoleProcessingSet.insert(procInverseRoleInvPair); |
| 505 |
eqInRoleProcessingList.append(procInverseRoleInvPair); |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
} else { |
| 512 |
|
| 513 |
for (CSortedNegLinker<CRole*>* eqInvRoleIt = role->getInverseEquivalentRoleList(); eqInvRoleIt; eqInvRoleIt = eqInvRoleIt->getNext()) { |
| 514 |
CRole* eqInvRole = eqInvRoleIt->getData(); |
| 515 |
if (eqInvRole != role) { |
| 516 |
mRedirectedRoleInstancesItemHash.insert(eqInvRole, new COptimizedKPSetRoleInstancesRedirectionItem(instancesItem, eqInvRole, eqInvRoleIt->isNegated())); |
| 517 |
} |
| 518 |
if (eqInvRoleIt->isNegated()) { |
| 519 |
inverseRole = eqInvRole; |
| 520 |
} |
| 521 |
} |
| 522 |
for (CSortedNegLinker<CRole*>* indSupRoleIt = role->getIndirectSuperRoleList(); indSupRoleIt; indSupRoleIt = indSupRoleIt->getNext()) { |
| 523 |
CRole* superRole = indSupRoleIt->getData(); |
| 524 |
bool superRoleInversed = indSupRoleIt->isNegated(); |
| 525 |
if (!mRedirectedRoleInstancesItemHash.contains(superRole)) { |
| 526 |
for (CSortedNegLinker<CRole*>* supIndSupRoleIt = superRole->getIndirectSuperRoleList(); supIndSupRoleIt; supIndSupRoleIt = supIndSupRoleIt->getNext()) { |
| 527 |
CRole* superSuperRole = supIndSupRoleIt->getData(); |
| 528 |
if (role == superSuperRole) { |
| 529 |
mRedirectedRoleInstancesItemHash.insert(superRole,new COptimizedKPSetRoleInstancesRedirectionItem(instancesItem,superSuperRole,superRoleInversed)); |
| 530 |
if (superRoleInversed) { |
| 531 |
inverseRole = superRole; |
| 532 |
} |
| 533 |
} |
| 534 |
} |
| 535 |
} |
| 536 |
} |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
if (inverseRole) { |
| 541 |
if (!instancesItem->hasInverseRole()) { |
| 542 |
instancesItem->setInverseRole(inverseRole); |
| 543 |
} |
| 544 |
} |
| 545 |
|
| 546 |
if (role->isComplexRole()) { |
| 547 |
mComplexRoleInstancesItemContainer.append(instancesItem); |
| 548 |
} |
| 549 |
} |
| 550 |
} |
| 551 |
|
| 552 |
CRole* topRole = rbox->getTopObjectRole(); |
| 553 |
CRole* bottomRole = rbox->getBottomObjectRole(); |
| 554 |
|
| 555 |
mTopRoleInstancesItem = mRedirectedRoleInstancesItemHash.value(rbox->getTopObjectRole())->getRedirectedItem(); |
| 556 |
mBottomRoleInstancesItem = mRedirectedRoleInstancesItemHash.value(rbox->getBottomObjectRole())->getRedirectedItem(); |
| 557 |
|
| 558 |
for (QList<COptimizedKPSetRoleInstancesItem*>::const_iterator it = mRoleInstancesItemContainer.constBegin(), itEnd = mRoleInstancesItemContainer.constEnd(); it != itEnd; ++it) { |
| 559 |
COptimizedKPSetRoleInstancesItem* roleItem(*it); |
| 560 |
CRole* role = roleItem->getRole(); |
| 561 |
for (CSortedNegLinker<CRole*>* eqInvRoleIt = role->getInverseEquivalentRoleList(); eqInvRoleIt; eqInvRoleIt = eqInvRoleIt->getNext()) { |
| 562 |
CRole* eqInvRole = eqInvRoleIt->getData(); |
| 563 |
bool inversed = eqInvRoleIt->isNegated(); |
| 564 |
for (CSortedNegLinker<CRole*>* eqInvSupRoleIt = eqInvRole->getSuperRoleList(); eqInvSupRoleIt; eqInvSupRoleIt = eqInvSupRoleIt->getNext()) { |
| 565 |
CRole* superRole = eqInvSupRoleIt->getData(); |
| 566 |
bool superRoleInversed = eqInvSupRoleIt->isNegated() ^ inversed; |
| 567 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleRedirectionItem = mRedirectedRoleInstancesItemHash.value(superRole); |
| 568 |
if (redRoleRedirectionItem) { |
| 569 |
COptimizedKPSetRoleInstancesItem* superRoleRedirectedItem = redRoleRedirectionItem->getRedirectedItem(); |
| 570 |
bool superRoleRedirectionInversed = redRoleRedirectionItem->isInversed() ^ superRoleInversed; |
| 571 |
if (superRoleRedirectedItem != roleItem) { |
| 572 |
roleItem->addParentItem(superRoleRedirectedItem, superRoleRedirectionInversed); |
| 573 |
superRoleRedirectedItem->addSuccessorItem(roleItem, superRoleRedirectionInversed); |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
} |
| 578 |
if (roleItem->getParentItemList()->isEmpty() && roleItem != mTopRoleInstancesItem) { |
| 579 |
roleItem->addParentItem(mTopRoleInstancesItem,false); |
| 580 |
mTopRoleInstancesItem->addSuccessorItem(roleItem,false); |
| 581 |
} |
| 582 |
} |
| 583 |
|
| 584 |
for (QList<COptimizedKPSetRoleInstancesItem*>::const_iterator it = mRoleInstancesItemContainer.constBegin(), itEnd = mRoleInstancesItemContainer.constEnd(); it != itEnd; ++it) { |
| 585 |
COptimizedKPSetRoleInstancesItem* item(*it); |
| 586 |
item->setInitialUnprocessedSuccessorItemCount(); |
| 587 |
if (item->getUnprocessedSuccessorItemCount() <= 0) { |
| 588 |
item->setAllSuccessorProcessedFlag(true); |
| 589 |
} |
| 590 |
item->setInitialUninitializedSuccessorItemCount(); |
| 591 |
if (item->getUninitializedSuccessorItemCount() <= 0) { |
| 592 |
item->setAllSuccessorInitializedFlag(true); |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
} |
| 597 |
return this; |
| 598 |
} |
| 599 |
|
| 600 |
|
| 601 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasItemsInitialized() { |
| 602 |
return mItemsInitialized; |
| 603 |
} |
| 604 |
|
| 605 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setItemsInitialized(bool initialized) { |
| 606 |
mItemsInitialized = initialized; |
| 607 |
return this; |
| 608 |
} |
| 609 |
|
| 610 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRealizationSameIndividualsInitialized() { |
| 611 |
return mRealizationSameIndividualsInitialized; |
| 612 |
} |
| 613 |
|
| 614 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setRealizationSameIndividualsInitialized(bool initialized) { |
| 615 |
mRealizationSameIndividualsInitialized = initialized; |
| 616 |
return this; |
| 617 |
} |
| 618 |
|
| 619 |
|
| 620 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRealizationConceptsInitialized() { |
| 621 |
return mRealizationConceptsInitialized; |
| 622 |
} |
| 623 |
|
| 624 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setRealizationConceptsInitialized(bool initialized) { |
| 625 |
mRealizationConceptsInitialized = initialized; |
| 626 |
return this; |
| 627 |
} |
| 628 |
|
| 629 |
|
| 630 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRealizationRolesInitialized() { |
| 631 |
return mRealizationRolesInitialized; |
| 632 |
} |
| 633 |
|
| 634 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setRealizationRolesInitialized(bool initialized) { |
| 635 |
mRealizationRolesInitialized = initialized; |
| 636 |
return this; |
| 637 |
} |
| 638 |
|
| 639 |
|
| 640 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setTemporaryRoleRealizationOntology(CConcreteOntology* tmpOntology) { |
| 641 |
mTempRoleRealizationOntology = tmpOntology; |
| 642 |
return this; |
| 643 |
} |
| 644 |
|
| 645 |
CConcreteOntology* COptimizedRepresentativeKPSetOntologyRealizingItem::getTemporaryRoleRealizationOntology() { |
| 646 |
return mTempRoleRealizationOntology; |
| 647 |
} |
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::ensureIteratorPositionRealization(COntologyRealizingDynamicIteratorRequirmentDataCallback* iteratorReqDataCallback, COntologyRealizingDynamicRequirmentProcessingData* newReqProcDat, CRealizationIndividualInstanceItemReferenceIterator* iterator, const QList<CRealizationIndividualInstanceItemReferenceIterator*>& initializationCheckIteratorList) { |
| 653 |
|
| 654 |
bool processing = false; |
| 655 |
CRealizationIndividualInstanceItemReference currentPosIndiItemRef = iterator->currentIndividualInstanceItemReference(); |
| 656 |
//if (prevCheckingPosIndiItemRef.getIndividualID() != currentPosIndiItemRef.getIndividualID()) { |
| 657 |
// iterator2->begin(); |
| 658 |
// iterator2->requiresInitialization(); |
| 659 |
//} |
| 660 |
|
| 661 |
|
| 662 |
for (CRealizationIndividualInstanceItemReferenceIterator* initCheckIterator : initializationCheckIteratorList) { |
| 663 |
COptimizedRepresentativeKPSetIndividualRoleFillerItemIterator* individualRoleFillerIterator = dynamic_cast<COptimizedRepresentativeKPSetIndividualRoleFillerItemIterator*>(initCheckIterator); |
| 664 |
if (individualRoleFillerIterator && individualRoleFillerIterator->requiresInitialization()) { |
| 665 |
if (queueRoleInstanceRealization(newReqProcDat, individualRoleFillerIterator->getQueryingIndividualInstanceItemReference(), currentPosIndiItemRef, individualRoleFillerIterator->getQueryingRoleInstancesItem()->getRole(), individualRoleFillerIterator->getQueryingRoleInstancesItemInversion())) { |
| 666 |
iteratorReqDataCallback->incRoleRealizationCount(); |
| 667 |
processing = true; |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
COptimizedRepresentativeKPSetUnsortedIndividualRoleFillerItemIterator* unsortedIndividualRoleFillerIterator = dynamic_cast<COptimizedRepresentativeKPSetUnsortedIndividualRoleFillerItemIterator*>(initCheckIterator); |
| 672 |
if (unsortedIndividualRoleFillerIterator && unsortedIndividualRoleFillerIterator->requiresInitialization()) { |
| 673 |
if (queueRoleInstanceRealization(newReqProcDat, unsortedIndividualRoleFillerIterator->getQueryingIndividualInstanceItemReference(), currentPosIndiItemRef, unsortedIndividualRoleFillerIterator->getQueryingRoleInstancesItem()->getRole(), unsortedIndividualRoleFillerIterator->getQueryingRoleInstancesItemInversion())) { |
| 674 |
iteratorReqDataCallback->incRoleRealizationCount(); |
| 675 |
processing = true; |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator* roleNeighbouringIterator = dynamic_cast<COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator*>(initCheckIterator); |
| 680 |
if (roleNeighbouringIterator && roleNeighbouringIterator->requiresInitialization()) { |
| 681 |
QSet<TRoleInstancesItemInversedFlagPair>* roleInstancesItemInversedFlagPairSet = roleNeighbouringIterator->currentRoleInstancesItemInversionPairSet(); |
| 682 |
for (TRoleInstancesItemInversedFlagPair roleInstancesItemInversedFlagPair : *roleInstancesItemInversedFlagPairSet) { |
| 683 |
COptimizedKPSetRoleInstancesItem* roleItem = roleInstancesItemInversedFlagPair.first; |
| 684 |
bool roleItemInversion = roleInstancesItemInversedFlagPair.second; |
| 685 |
// TODO: initialize and determine only one certain filler |
| 686 |
if (queueRoleFillerInstanceRealization(newReqProcDat, currentPosIndiItemRef, roleItem->getRole(), roleItemInversion)) { |
| 687 |
iteratorReqDataCallback->incRoleRealizationCount(); |
| 688 |
processing = true; |
| 689 |
} |
| 690 |
} |
| 691 |
} |
| 692 |
|
| 693 |
COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator* conceptLabelIterator = dynamic_cast<COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator*>(initCheckIterator); |
| 694 |
if (conceptLabelIterator && conceptLabelIterator->requiresInitialization()) { |
| 695 |
QSet<TConceptInstancesItemMostSpecificFlagPair>* conceptInstancesItemOnlyMostSpecificFlagPairSet = conceptLabelIterator->currentConceptInstancesItemOnlyMostSpecificFlagPairSet(); |
| 696 |
for (TConceptInstancesItemMostSpecificFlagPair conceptInstancesItemOnlyMostSpecificFlagPair : *conceptInstancesItemOnlyMostSpecificFlagPairSet) { |
| 697 |
COptimizedKPSetConceptInstancesItem* conceptItem = conceptInstancesItemOnlyMostSpecificFlagPair.first; |
| 698 |
bool mostSpecificOnly = conceptInstancesItemOnlyMostSpecificFlagPair.second; |
| 699 |
if (queueConceptInstanceRealization(newReqProcDat, currentPosIndiItemRef, conceptItem->getHierarchyNode()->getOneEquivalentConcept(), mostSpecificOnly)) { |
| 700 |
iteratorReqDataCallback->incConceptRealizationCount(); |
| 701 |
processing = true; |
| 702 |
} |
| 703 |
} |
| 704 |
} |
| 705 |
} |
| 706 |
|
| 707 |
return processing; |
| 708 |
} |
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::handleIteratorRequirement(COntologyRealizingDynamicIteratorRequirmentDataCallback* iteratorReqDataCallback, COntologyRealizingDynamicRequirmentProcessingData* newReqProcDat, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 713 |
COntologyProcessingIteratorRealizationRequirement* dynamicIteratorRealReq = iteratorReqDataCallback->getRealizationIteratorRequirement(); |
| 714 |
CRealizationIndividualInstanceItemReferenceIterator* iterator = dynamicIteratorRealReq->getRealizationIterator(); |
| 715 |
|
| 716 |
cint64 realReqInstCount = dynamicIteratorRealReq->getRealizationRequiredInstancesCount(); |
| 717 |
|
| 718 |
QList<CRealizationIndividualInstanceItemReferenceIterator*> initializationCheckIteratorList; |
| 719 |
|
| 720 |
COptimizedRepresentativeKPSetIntersectionCombinationIterator* combinationIterator = dynamic_cast<COptimizedRepresentativeKPSetIntersectionCombinationIterator*>(iterator); |
| 721 |
if (combinationIterator) { |
| 722 |
initializationCheckIteratorList.append(*combinationIterator->getCombinedIteratorList()); |
| 723 |
} else { |
| 724 |
initializationCheckIteratorList.append(iterator); |
| 725 |
} |
| 726 |
|
| 727 |
bool processing = false; |
| 728 |
iterator->begin(); |
| 729 |
CRealizationIndividualInstanceItemReference currentPosIndiItemRef = iterator->currentIndividualInstanceItemReference(); |
| 730 |
if (iterator->requiresInitialization() && currentPosIndiItemRef.getIndividualID() == -1) { |
| 731 |
for (CRealizationIndividualInstanceItemReferenceIterator* initCheckIterator : initializationCheckIteratorList) { |
| 732 |
COptimizedRepresentativeKPSetIndividualRoleFillerItemIterator* individualRoleFillerIterator = dynamic_cast<COptimizedRepresentativeKPSetIndividualRoleFillerItemIterator*>(initCheckIterator); |
| 733 |
if (individualRoleFillerIterator && individualRoleFillerIterator->requiresInitialization()) { |
| 734 |
// TODO: only do initialization |
| 735 |
if (queueRoleFillerInstanceRealization(newReqProcDat, individualRoleFillerIterator->getQueryingIndividualInstanceItemReference(), individualRoleFillerIterator->getQueryingRoleInstancesItem()->getRole(), individualRoleFillerIterator->getQueryingRoleInstancesItemInversion())) { |
| 736 |
iteratorReqDataCallback->incRoleInitializationCount(); |
| 737 |
processing = true; |
| 738 |
} |
| 739 |
} |
| 740 |
COptimizedRepresentativeKPSetUnsortedIndividualRoleFillerItemIterator* unsortedIndividualRoleFillerIterator = dynamic_cast<COptimizedRepresentativeKPSetUnsortedIndividualRoleFillerItemIterator*>(initCheckIterator); |
| 741 |
if (unsortedIndividualRoleFillerIterator && unsortedIndividualRoleFillerIterator->requiresInitialization()) { |
| 742 |
// TODO: only do initialization |
| 743 |
if (queueRoleFillerInstanceRealization(newReqProcDat, unsortedIndividualRoleFillerIterator->getQueryingIndividualInstanceItemReference(), unsortedIndividualRoleFillerIterator->getQueryingRoleInstancesItem()->getRole(), unsortedIndividualRoleFillerIterator->getQueryingRoleInstancesItemInversion())) { |
| 744 |
iteratorReqDataCallback->incRoleInitializationCount(); |
| 745 |
processing = true; |
| 746 |
} |
| 747 |
} |
| 748 |
} |
| 749 |
} |
| 750 |
|
| 751 |
if (!processing) { |
| 752 |
//CRealizationIndividualInstanceItemReference prevCheckingPosIndiItemRef = iterator->currentIndividualInstanceItemReference(); |
| 753 |
//CRealizationIndividualInstanceItemReferenceIterator* iterator2 = iterator->getCopy(); |
| 754 |
if (!iterator->atEnd() && !processing && (realReqInstCount < 0 || iteratorReqDataCallback->getFoundInstancesCount() < realReqInstCount)) { |
| 755 |
if (iterator->requiresInitialization()) { |
| 756 |
|
| 757 |
cint64 schedulingIndividualCount = 0; |
| 758 |
processing = ensureIteratorPositionRealization(iteratorReqDataCallback, newReqProcDat, iterator, initializationCheckIteratorList); |
| 759 |
if (processing) { |
| 760 |
++schedulingIndividualCount; |
| 761 |
} |
| 762 |
if (realReqInstCount >= 1 && iteratorReqDataCallback->getConceptRealizationCount() > 3 && iteratorReqDataCallback->getFoundInstancesCount() <= 0) { |
| 763 |
// to utilize possible instance mergings |
| 764 |
realReqInstCount += iteratorReqDataCallback->getConceptRealizationCount() / 2; |
| 765 |
} |
| 766 |
|
| 767 |
if (processing && (realReqInstCount < 0 || realReqInstCount > 1 && iteratorReqDataCallback->getFoundInstancesCount() + schedulingIndividualCount < realReqInstCount)) { |
| 768 |
CRealizationIndividualInstanceItemReferenceIterator* iteratorCopy = iterator->getCopy(); |
| 769 |
//CRealizationIndividualInstanceItemReferenceIterator* iteratorCopy2 = iterator->getCopy(); |
| 770 |
iteratorCopy->moveNext(); |
| 771 |
QList<CRealizationIndividualInstanceItemReferenceIterator*> initializationCheckIteratorCopyList; |
| 772 |
COptimizedRepresentativeKPSetIntersectionCombinationIterator* combinationIteratorCopy = dynamic_cast<COptimizedRepresentativeKPSetIntersectionCombinationIterator*>(iteratorCopy); |
| 773 |
if (combinationIteratorCopy) { |
| 774 |
initializationCheckIteratorCopyList.append(*combinationIteratorCopy->getCombinedIteratorList()); |
| 775 |
} else { |
| 776 |
initializationCheckIteratorCopyList.append(iteratorCopy); |
| 777 |
} |
| 778 |
while (!iteratorCopy->atEnd() && (realReqInstCount < 0 || realReqInstCount > 1 && iteratorReqDataCallback->getFoundInstancesCount() + schedulingIndividualCount < realReqInstCount)) { |
| 779 |
CRealizationIndividualInstanceItemReference currentCopyPosIndiItemRef = iteratorCopy->currentIndividualInstanceItemReference(); |
| 780 |
if (currentCopyPosIndiItemRef.getIndividualID() == -1 || iteratorCopy->requiresInitialization()) { |
| 781 |
if (ensureIteratorPositionRealization(iteratorReqDataCallback, newReqProcDat, iteratorCopy, initializationCheckIteratorCopyList)) { |
| 782 |
++schedulingIndividualCount; |
| 783 |
} |
| 784 |
} |
| 785 |
if (currentCopyPosIndiItemRef.getIndividualID() == -1) { |
| 786 |
//iteratorCopy2->moveNext(); |
| 787 |
//CRealizationIndividualInstanceItemReference currentPosIndiItemRef2 = iteratorCopy2->currentIndividualInstanceItemReference(); |
| 788 |
break; |
| 789 |
} |
| 790 |
//iteratorCopy2->moveNext(); |
| 791 |
//CRealizationIndividualInstanceItemReference currentPosIndiItemRef2 = iteratorCopy2->currentIndividualInstanceItemReference(); |
| 792 |
iteratorCopy->moveNext(); |
| 793 |
} |
| 794 |
//LOG(NOTICE, "::Konclude::Reasoner::Kernel::Realizer", logTr("Scheduling realization for %1 individuals for preparing realization iterator.").arg(schedulingIndividualCount), this); |
| 795 |
if (realReqInstCount < 0) { |
| 796 |
iteratorReqDataCallback->setRealizedAllInstances(true); |
| 797 |
} |
| 798 |
delete iteratorCopy; |
| 799 |
} |
| 800 |
|
| 801 |
if (procData->getStatistics()) { |
| 802 |
procData->getStatistics()->incmIteratorScheduledIndividualRealizationCount(schedulingIndividualCount); |
| 803 |
} |
| 804 |
|
| 805 |
} else { |
| 806 |
CRealizationIndividualInstanceItemReference currentPosIndiItemRef = iterator->currentIndividualInstanceItemReference(); |
| 807 |
if (currentPosIndiItemRef.getIndividualID() != -1) { |
| 808 |
iteratorReqDataCallback->incFoundInstancesCount(1); |
| 809 |
} |
| 810 |
} |
| 811 |
} |
| 812 |
|
| 813 |
// TODO: do realization for the number of individuals for which it is requested, i.e., realReqInstCount |
| 814 |
} |
| 815 |
return processing; |
| 816 |
|
| 817 |
} |
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
COntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::logRequirementProcessingStartStatistics(COntologyRealizingDynamicRequirmentProcessingStatistics* procStats) { |
| 822 |
if (procStats) { |
| 823 |
if (procStats->getIteratorPreparationStartingCount() > 0) { |
| 824 |
LOG(NOTICE, "::Konclude::Reasoner::Kernel::Realizer", logTr("Starting preparation of %1 realization iterators.").arg(procStats->getIteratorPreparationStartingCount()), this); |
| 825 |
} |
| 826 |
} |
| 827 |
return this; |
| 828 |
} |
| 829 |
|
| 830 |
|
| 831 |
COntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::logRequirementProcessingFinishStatistics(COntologyRealizingDynamicRequirmentProcessingStatistics* procStats) { |
| 832 |
if (procStats) { |
| 833 |
if (procStats->getIteratorPreparationFinsihingCount() > 0) { |
| 834 |
LOG(NOTICE, "::Konclude::Reasoner::Kernel::Realizer", logTr("Scheduled realization for %1 individuals for preparing %2 realization iterator.").arg(procStats->getmIteratorScheduledIndividualRealizationCount()).arg(procStats->getIteratorPreparationFinsihingCount()), this); |
| 835 |
LOG(NOTICE, "::Konclude::Reasoner::Kernel::Realizer", logTr("Finished preparing of %1 realization iterator with %2 role realization initializations as well as %3 role and %4 concept possible instance realizations.") |
| 836 |
.arg(procStats->getIteratorPreparationFinsihingCount()).arg(procStats->getIteratorRoleInstancesInitializationCount()).arg(procStats->getIteratorRoleInstancesRealizationCount()).arg(procStats->getIteratorConceptInstancesRealizationCount()), this); |
| 837 |
} |
| 838 |
} |
| 839 |
return this; |
| 840 |
} |
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
COntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addProcessingRequirement(COntologyProcessingRequirement* ontoRequirement, COntologyRealizingDynamicRequirmentProcessingData* procData) { |
| 845 |
bool supportRequirement = false; |
| 846 |
COntologyProcessingStepRequirement* stepProcRequirement = dynamic_cast<COntologyProcessingStepRequirement*>(ontoRequirement); |
| 847 |
if (stepProcRequirement) { |
| 848 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSINITREALIZE) { |
| 849 |
supportRequirement = true; |
| 850 |
if (!mInitRealizeProcessingStep->isStepFinished()) { |
| 851 |
procData->setAssociatedRelizationTestingStep(mInitRealizeProcessingStep); |
| 852 |
getInitRealizeProcessingStep()->addRequirementProcessingData(procData); |
| 853 |
} |
| 854 |
} else if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSCONCEPTREALIZE) { |
| 855 |
markIntanceItemForConceptRealization(procData, mOntology->getTBox()->getTopConcept()); |
| 856 |
supportRequirement = true; |
| 857 |
} else if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSROLEREALIZE) { |
| 858 |
markIntanceItemForRoleRealization(procData, mOntology->getRBox()->getTopObjectRole()); |
| 859 |
supportRequirement = true; |
| 860 |
} else if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSSAMEINDIVIDUALSREALIZE) { |
| 861 |
markInstantiatedItemForSameIndividualsRealization(procData, CIndividualReference()); |
| 862 |
supportRequirement = true; |
| 863 |
} |
| 864 |
} |
| 865 |
|
| 866 |
COntologyProcessingDynamicRealizationRequirement* dynamicRealRequirment = dynamic_cast<COntologyProcessingDynamicRealizationRequirement*>(ontoRequirement); |
| 867 |
if (dynamicRealRequirment) { |
| 868 |
|
| 869 |
COntologyProcessingInitializedRealizationRequirement* initRequirement = dynamic_cast<COntologyProcessingInitializedRealizationRequirement*>(dynamicRealRequirment); |
| 870 |
if (initRequirement) { |
| 871 |
supportRequirement = true; |
| 872 |
if (!mInitRealizeProcessingStep->isStepFinished()) { |
| 873 |
procData->setAssociatedRelizationTestingStep(mInitRealizeProcessingStep); |
| 874 |
getInitRealizeProcessingStep()->addRequirementProcessingData(procData); |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
|
| 879 |
COntologyRealizingDynamicIteratorRequirmentDataCallback* dynamicIteratorReapRealReq = dynamic_cast<COntologyRealizingDynamicIteratorRequirmentDataCallback*>(dynamicRealRequirment); |
| 880 |
if (dynamicIteratorReapRealReq) { |
| 881 |
procData->decProcessingItemCount(nullptr); |
| 882 |
bool finishIteratorHandling = false; |
| 883 |
if (!dynamicIteratorReapRealReq->hasRealizedAllInstances()) { |
| 884 |
COntologyRealizingDynamicRequirmentCallbackData* reqCallbackData = new COntologyRealizingDynamicRequirmentCallbackData(dynamicIteratorReapRealReq); |
| 885 |
reqCallbackData->incProcessingRequirmentCount(); |
| 886 |
COntologyRealizingDynamicRequirmentProcessingData* newReqProcDat = new COntologyRealizingDynamicRequirmentProcessingData(dynamicIteratorReapRealReq, reqCallbackData); |
| 887 |
|
| 888 |
|
| 889 |
if (handleIteratorRequirement(dynamicIteratorReapRealReq, newReqProcDat, procData)) { |
| 890 |
procData->incProcessingItemCount(nullptr); |
| 891 |
} else { |
| 892 |
finishIteratorHandling = true; |
| 893 |
delete newReqProcDat; |
| 894 |
delete reqCallbackData; |
| 895 |
} |
| 896 |
} else { |
| 897 |
finishIteratorHandling = true; |
| 898 |
} |
| 899 |
if (finishIteratorHandling) { |
| 900 |
if (procData->getStatistics()) { |
| 901 |
procData->getStatistics()->incIteratorRoleInstancesInitializationCount(dynamicIteratorReapRealReq->getRoleInitializationCount()); |
| 902 |
procData->getStatistics()->incIteratorRoleInstancesRealizationCount(dynamicIteratorReapRealReq->getRoleRealizationCount()); |
| 903 |
procData->getStatistics()->incIteratorConceptInstancesRealizationCount(dynamicIteratorReapRealReq->getConceptRealizationCount()); |
| 904 |
procData->getStatistics()->incIteratorPreparationFinsihingCount(); |
| 905 |
} |
| 906 |
} |
| 907 |
|
| 908 |
supportRequirement = true; |
| 909 |
} |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
COntologyProcessingIteratorRealizationRequirement* dynamicIteratorRealReq = dynamic_cast<COntologyProcessingIteratorRealizationRequirement*>(dynamicRealRequirment); |
| 914 |
if (dynamicIteratorRealReq) { |
| 915 |
|
| 916 |
COntologyRealizingDynamicIteratorRequirmentDataCallback* iteratorReqDataCallback = new COntologyRealizingDynamicIteratorRequirmentDataCallback(procData, this, dynamicIteratorRealReq); |
| 917 |
COntologyRealizingDynamicRequirmentCallbackData* reqCallbackData = new COntologyRealizingDynamicRequirmentCallbackData(iteratorReqDataCallback); |
| 918 |
reqCallbackData->incProcessingRequirmentCount(); |
| 919 |
COntologyRealizingDynamicRequirmentProcessingData* newReqProcDat = new COntologyRealizingDynamicRequirmentProcessingData(iteratorReqDataCallback, reqCallbackData); |
| 920 |
|
| 921 |
if (procData->getStatistics()) { |
| 922 |
procData->getStatistics()->incIteratorPreparationStartingCount(); |
| 923 |
} |
| 924 |
if (handleIteratorRequirement(iteratorReqDataCallback, newReqProcDat, procData)) { |
| 925 |
procData->incProcessingItemCount(nullptr); |
| 926 |
} else { |
| 927 |
if (!mIteratorNothingToDoWarning) { |
| 928 |
LOG(WARN, "::Konclude::Reasoner::Kernel::Realizer", logTr("Nothing to do for realization iterator."), this); |
| 929 |
mIteratorNothingToDoWarning = true; |
| 930 |
} |
| 931 |
delete newReqProcDat; |
| 932 |
delete reqCallbackData; |
| 933 |
} |
| 934 |
|
| 935 |
supportRequirement = true; |
| 936 |
} |
| 937 |
|
| 938 |
|
| 939 |
COntologyProcessingSameRealizationRequirement* dynamicSameRealReq = dynamic_cast<COntologyProcessingSameRealizationRequirement*>(dynamicRealRequirment); |
| 940 |
if (dynamicSameRealReq) { |
| 941 |
CIndividualReference indiSource = dynamicSameRealReq->getIndividualSourceReference(); |
| 942 |
CIndividualReference indiDest = dynamicSameRealReq->getIndividualDestinationReference(); |
| 943 |
if (indiDest.isNonEmpty() && indiSource.isEmpty()) { |
| 944 |
indiSource = indiDest; |
| 945 |
indiDest = CIndividualReference(); |
| 946 |
} |
| 947 |
if (indiDest.isEmpty()) { |
| 948 |
markInstantiatedItemForSameIndividualsRealization(procData, indiSource); |
| 949 |
} else { |
| 950 |
queueSameInstanceRealization(procData, indiSource, indiDest); |
| 951 |
} |
| 952 |
supportRequirement = true; |
| 953 |
} |
| 954 |
COntologyProcessingConceptRealizationRequirement* dynamicConRealReq = dynamic_cast<COntologyProcessingConceptRealizationRequirement*>(dynamicRealRequirment); |
| 955 |
if (dynamicConRealReq) { |
| 956 |
CConcept* concept = dynamicConRealReq->getConcept(); |
| 957 |
CIndividualReference indi = dynamicConRealReq->getIndividualReference(); |
| 958 |
if (indi.isEmpty()) { |
| 959 |
markIntanceItemForConceptRealization(procData, concept); |
| 960 |
} else { |
| 961 |
bool subConceptRealisation = dynamicConRealReq->realizeSubConcepts(); |
| 962 |
queueConceptInstanceRealization(procData, indi, concept, subConceptRealisation); |
| 963 |
} |
| 964 |
supportRequirement = true; |
| 965 |
} |
| 966 |
COntologyProcessingRoleRealizationRequirement* dynamicRoleRealReq = dynamic_cast<COntologyProcessingRoleRealizationRequirement*>(dynamicRealRequirment); |
| 967 |
if (dynamicRoleRealReq) { |
| 968 |
CIndividualReference indiSource = dynamicRoleRealReq->getIndividualSourceReference(); |
| 969 |
CIndividualReference indiDestination = dynamicRoleRealReq->getIndividualDestinationReference(); |
| 970 |
CRole* role = dynamicRoleRealReq->getRole(); |
| 971 |
bool inversed = dynamicRoleRealReq->isRoleInversed(); |
| 972 |
if (indiSource.isEmpty() && indiDestination.isEmpty()) { |
| 973 |
markIntanceItemForRoleRealization(procData, role); |
| 974 |
} else if (indiSource.isNonEmpty() && indiDestination.isNonEmpty()) { |
| 975 |
if (role) { |
| 976 |
queueRoleInstanceRealization(procData, indiSource, indiDestination, role, inversed); |
| 977 |
} else { |
| 978 |
for (QList<COptimizedKPSetRoleInstancesItem*>::const_iterator it = mRoleInstancesItemContainer.constBegin(), itEnd = mRoleInstancesItemContainer.constEnd(); it != itEnd; ++it) { |
| 979 |
COptimizedKPSetRoleInstancesItem* roleItem(*it); |
| 980 |
CRole* role = roleItem->getRole(); |
| 981 |
queueRoleInstanceRealization(procData, indiSource, indiDestination, role, inversed); |
| 982 |
} |
| 983 |
} |
| 984 |
} else if (indiSource.isNonEmpty() || indiDestination.isNonEmpty()) { |
| 985 |
if (indiSource.isEmpty()) { |
| 986 |
indiSource = indiDestination; |
| 987 |
inversed = !inversed; |
| 988 |
indiDestination = CIndividualReference(); |
| 989 |
} |
| 990 |
if (role) { |
| 991 |
queueRoleFillerInstanceRealization(procData, indiSource, role, inversed); |
| 992 |
} else { |
| 993 |
for (QList<COptimizedKPSetRoleInstancesItem*>::const_iterator it = mRoleInstancesItemContainer.constBegin(), itEnd = mRoleInstancesItemContainer.constEnd(); it != itEnd; ++it) { |
| 994 |
COptimizedKPSetRoleInstancesItem* roleItem(*it); |
| 995 |
CRole* role = roleItem->getRole(); |
| 996 |
queueRoleFillerInstanceRealization(procData, indiSource, role, inversed); |
| 997 |
} |
| 998 |
} |
| 999 |
} |
| 1000 |
supportRequirement = true; |
| 1001 |
} |
| 1002 |
} |
| 1003 |
if (procData && !procData->hasCurrentProcessingItemCount()) { |
| 1004 |
ontoRequirement->submitRequirementUpdate(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, COntologyProcessingStatus::PSSUCESSFULL); |
| 1005 |
if (procData->getCallbackData()) { |
| 1006 |
COntologyRealizingDynamicRequirmentCallbackData* callbackData = procData->getCallbackData(); |
| 1007 |
callbackData->decProcessingRequirmentCount(); |
| 1008 |
if (!callbackData->hasCurrentProcessingRequirmentCount()) { |
| 1009 |
logRequirementProcessingFinishStatistics(procData->getStatistics()); |
| 1010 |
callbackData->getProcessingFinishedCallback()->doCallback(); |
| 1011 |
delete callbackData; |
| 1012 |
} |
| 1013 |
} |
| 1014 |
delete procData; |
| 1015 |
} |
| 1016 |
if (!supportRequirement) { |
| 1017 |
ontoRequirement->submitRequirementUpdate(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSUNSUPPORTED); |
| 1018 |
} |
| 1019 |
return this; |
| 1020 |
} |
| 1021 |
|
| 1022 |
|
| 1023 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleInstanceItemToProcessPossibleInstances(COptimizedKPSetRoleInstancesItem* instanceItem) { |
| 1024 |
if (!instanceItem->hasPossibleInstancesProcessingQueuedFlag()) { |
| 1025 |
if (instanceItem->hasPossibleInstances()) { |
| 1026 |
mProcessingPossibleRoleInstancesItemList.append(instanceItem); |
| 1027 |
instanceItem->setPossibleInstancesProcessingQueuedFlag(true); |
| 1028 |
} |
| 1029 |
} |
| 1030 |
return this; |
| 1031 |
} |
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleInstanceItemToProcessComplexCandidateInstances(COptimizedKPSetRoleInstancesItem* instanceItem) { |
| 1038 |
if (!instanceItem->hasComplexCandidateInstancesProcessingQueuedFlag()) { |
| 1039 |
if (instanceItem->hasComplexInstanceCandidates()) { |
| 1040 |
mCandidateConfirmationRoleInstancesItemList.append(instanceItem); |
| 1041 |
instanceItem->setComplexCandidateProcessingQueuedFlag(true); |
| 1042 |
} |
| 1043 |
} |
| 1044 |
return this; |
| 1045 |
} |
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addConceptInstanceItemToProcessPossibleInstances(COptimizedKPSetConceptInstancesItem* instanceItem) { |
| 1051 |
if (!instanceItem->hasPossibleInstancesProcessingQueuedFlag()) { |
| 1052 |
if (instanceItem->hasPossibleInstances()) { |
| 1053 |
mProcessingConceptInstancesItemList.append(instanceItem); |
| 1054 |
instanceItem->setPossibleInstancesProcessingQueuedFlag(true); |
| 1055 |
} |
| 1056 |
} |
| 1057 |
return this; |
| 1058 |
} |
| 1059 |
|
| 1060 |
|
| 1061 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleInstanceItemToInitializeCandidates(COptimizedKPSetRoleInstancesItem* instanceItem) { |
| 1062 |
if (!instanceItem->hasInitializingQueuedFlag()) { |
| 1063 |
if (instanceItem->requiresCandidateInitialization()) { |
| 1064 |
mInitializingRoleInstancesItemList.append(instanceItem); |
| 1065 |
instanceItem->setInitializingQueuedFlag(true); |
| 1066 |
} |
| 1067 |
} |
| 1068 |
return this; |
| 1069 |
} |
| 1070 |
|
| 1071 |
|
| 1072 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleInstanceIndividualItemToInitializeCandidates(COptimizedKPSetIndividualItem* indiItem) { |
| 1073 |
if (!indiItem->hasInitializingRoleCandidatesQueuedFlag()) { |
| 1074 |
addRoleInstanceIndividualItemToInitializeCandidates(CRealizationIndividualInstanceItemReference(indiItem->getIndividualReference(), indiItem)); |
| 1075 |
indiItem->setInitializingRoleCandidatesQueuedFlag(true); |
| 1076 |
} |
| 1077 |
return this; |
| 1078 |
} |
| 1079 |
|
| 1080 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleInstanceIndividualItemToInitializeCandidates(const CRealizationIndividualInstanceItemReference& indiRealItemRef) { |
| 1081 |
mInitializingRoleInstancesIndividualItemReferenceList.append(indiRealItemRef); |
| 1082 |
return this; |
| 1083 |
} |
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleSuccessorInstanceIndividualItemPairToInitializeCandidates(const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetRoleInstancesItem* instanceItem) { |
| 1088 |
mInitializingRoleSuccessorInstancesIndividualItemReferencePairList.append(QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*>(indiRealItemRef, instanceItem)); |
| 1089 |
return this; |
| 1090 |
} |
| 1091 |
|
| 1092 |
|
| 1093 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRolePredecessorInstanceIndividualItemPairToInitializeCandidates(const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetRoleInstancesItem* instanceItem) { |
| 1094 |
mInitializingRolePredecessorInstancesIndividualItemReferencePairList.append(QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*>(indiRealItemRef, instanceItem)); |
| 1095 |
return this; |
| 1096 |
} |
| 1097 |
|
| 1098 |
|
| 1099 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addInstantiatedItemToProcessPossibleSameIndividuals(COptimizedKPSetIndividualItem* instantiatedItem) { |
| 1100 |
if (!instantiatedItem->hasPossibleSameIndividualsProcessingQueuedFlag()) { |
| 1101 |
if (instantiatedItem->hasPossibleSameIndividuals()) { |
| 1102 |
mProcessingSameIndividualsItemList.append(instantiatedItem); |
| 1103 |
instantiatedItem->setPossibleSameIndividualsProcessingQueuedFlag(true); |
| 1104 |
} |
| 1105 |
} |
| 1106 |
return this; |
| 1107 |
} |
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::markIntanceItemForRoleRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, CRole* role, bool subroleRealizationRequired) { |
| 1112 |
if (role == mOntology->getRBox()->getTopObjectRole()) { |
| 1113 |
setAllRoleInstancesProcessing(true); |
| 1114 |
} |
| 1115 |
bool roleItemQueued = false; |
| 1116 |
COptimizedKPSetRoleInstancesRedirectionItem* initialRedirectionItem = mRedirectedRoleInstancesItemHash.value(role); |
| 1117 |
QList<COptimizedKPSetRoleInstancesItem*> itemList; |
| 1118 |
QSet<COptimizedKPSetRoleInstancesItem*> itemSet; |
| 1119 |
itemList.append(initialRedirectionItem->getRedirectedItem()); |
| 1120 |
itemSet.insert(initialRedirectionItem->getRedirectedItem()); |
| 1121 |
while (!itemList.isEmpty()) { |
| 1122 |
COptimizedKPSetRoleInstancesItem* item = itemList.takeFirst(); |
| 1123 |
if (!item->hasToProcessPossibleInstancesFlag() || !item->hasToInitializeCandidatesFlag()) { |
| 1124 |
item->setToProcessPossibleInstancesFlag(true); |
| 1125 |
item->setToInitializeCandidatesFlag(true); |
| 1126 |
if (procData && (item->hasPossibleInstances() || item->hasComplexInstanceCandidates())) { |
| 1127 |
procData->incProcessingItemCount(mRealizeRoleProcessingStep); |
| 1128 |
item->addRequirementProcessingDataLinker(createRequirementProcessingDataLinker(procData)); |
| 1129 |
roleItemQueued = true; |
| 1130 |
} |
| 1131 |
addRoleInstanceItemToInitializeCandidates(item); |
| 1132 |
addRoleInstanceItemToProcessPossibleInstances(item); |
| 1133 |
addRoleInstanceItemToProcessComplexCandidateInstances(item); |
| 1134 |
} |
| 1135 |
if (subroleRealizationRequired) { |
| 1136 |
QList<TRoleItemInversionPair>* succItemList = item->getSuccessorItemList(); |
| 1137 |
for (QList<TRoleItemInversionPair>::const_iterator it = succItemList->constBegin(), itEnd = succItemList->constEnd(); it != itEnd; ++it) { |
| 1138 |
TRoleItemInversionPair succItemPair(*it); |
| 1139 |
if (!itemSet.contains(succItemPair.first)) { |
| 1140 |
itemSet.insert(succItemPair.first); |
| 1141 |
itemList.append(succItemPair.first); |
| 1142 |
} |
| 1143 |
} |
| 1144 |
} |
| 1145 |
} |
| 1146 |
|
| 1147 |
if (roleItemQueued || isAllRoleInstancesProcessing() && !getRealizeRoleProcessingStep()->isStepFinished()) { |
| 1148 |
if (!roleItemQueued || isAllRoleInstancesProcessing()) { |
| 1149 |
procData->incProcessingItemCount(mRealizeRoleProcessingStep); |
| 1150 |
} |
| 1151 |
procData->setAssociatedRelizationTestingStep(mRealizeRoleProcessingStep); |
| 1152 |
getRealizeRoleProcessingStep()->addRequirementProcessingData(procData); |
| 1153 |
} |
| 1154 |
|
| 1155 |
return this; |
| 1156 |
} |
| 1157 |
|
| 1158 |
|
| 1159 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::queueConceptInstanceRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, const CIndividualReference& indi, CConcept* concept, bool subconceptRealizationRequired) { |
| 1160 |
if (concept == nullptr) { |
| 1161 |
concept = mOntology->getTBox()->getTopConcept(); |
| 1162 |
subconceptRealizationRequired = true; |
| 1163 |
} |
| 1164 |
COptimizedKPSetIndividualItem* indiItem = (COptimizedKPSetIndividualItem*)getInstanceItem(indi, true); |
| 1165 |
|
| 1166 |
bool conceptItemQueued = false; |
| 1167 |
if (indiItem) { |
| 1168 |
COptimizedKPSetConceptInstancesItem* initConceptItem = mConceptInstancesItemHash.value(concept); |
| 1169 |
|
| 1170 |
QList<COptimizedKPSetConceptInstancesItem*> itemList; |
| 1171 |
QSet<COptimizedKPSetConceptInstancesItem*> itemSet; |
| 1172 |
itemList.append(initConceptItem); |
| 1173 |
itemSet.insert(initConceptItem); |
| 1174 |
|
| 1175 |
while (!itemList.isEmpty()) { |
| 1176 |
COptimizedKPSetConceptInstancesItem* conceptItem = itemList.takeFirst(); |
| 1177 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = indiItem->getKnownPossibleInstancesHash(); |
| 1178 |
COptimizedKPSetConceptInstancesHashData hashData = knownPossibleInstancesHash->value(conceptItem); |
| 1179 |
if (hashData.mInstanceItemData) { |
| 1180 |
if (!hashData.mInstanceItemData->mKnownInstance && hashData.mInstanceItemData->mPossibleInstance && !hashData.mInstanceItemData->mTestedInstance) { |
| 1181 |
if (!subconceptRealizationRequired && !hashData.mInstanceItemData->mMostSpecific && !conceptItem->getPossibleInstancesMap()->contains(indi.getIndividualID())) { |
| 1182 |
conceptItem->getPossibleInstancesMap()->insert(indi.getIndividualID(), indiItem); |
| 1183 |
} |
| 1184 |
if (conceptItem->getPossibleInstancesMap()->contains(indi.getIndividualID())) { |
| 1185 |
QMap<cint64, COptimizedKPSetIndividualItem*>*& prefConInstMap = conceptItem->getPrefferedPossibleInstanceTestingSet(); |
| 1186 |
if (!prefConInstMap) { |
| 1187 |
prefConInstMap = new QMap<cint64, COptimizedKPSetIndividualItem *>(); |
| 1188 |
} |
| 1189 |
prefConInstMap->insert(indi.getIndividualID(), indiItem); |
| 1190 |
} |
| 1191 |
CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem* incConInstTestItem = new CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem(indiItem, conceptItem, procData); |
| 1192 |
procData->incProcessingItemCount(mRealizeConceptProcessingStep); |
| 1193 |
addEntailmentIndividualConceptInstanceTestingItem(incConInstTestItem); |
| 1194 |
conceptItemQueued = true; |
| 1195 |
} |
| 1196 |
} |
| 1197 |
if (subconceptRealizationRequired) { |
| 1198 |
QList<COptimizedKPSetConceptInstancesItem*>* succItemList = conceptItem->getSuccessorItemList(); |
| 1199 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = succItemList->constBegin(), itEnd = succItemList->constEnd(); it != itEnd; ++it) { |
| 1200 |
COptimizedKPSetConceptInstancesItem* succItem(*it); |
| 1201 |
if (!itemSet.contains(succItem)) { |
| 1202 |
itemSet.insert(succItem); |
| 1203 |
itemList.append(succItem); |
| 1204 |
} |
| 1205 |
} |
| 1206 |
} |
| 1207 |
} |
| 1208 |
} |
| 1209 |
|
| 1210 |
if (conceptItemQueued) { |
| 1211 |
procData->setAssociatedRelizationTestingStep(mRealizeConceptProcessingStep); |
| 1212 |
getRealizeConceptProcessingStep()->addRequirementProcessingData(procData); |
| 1213 |
return true; |
| 1214 |
} else { |
| 1215 |
return false; |
| 1216 |
} |
| 1217 |
|
| 1218 |
} |
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::queueSameInstanceRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, const CIndividualReference& indi1, const CIndividualReference& indi2) { |
| 1224 |
COptimizedKPSetIndividualItem* indiItem1 = (COptimizedKPSetIndividualItem*)getInstanceItem(indi1, true); |
| 1225 |
COptimizedKPSetIndividualItem* indiItem2 = (COptimizedKPSetIndividualItem*)getInstanceItem(indi2, true); |
| 1226 |
|
| 1227 |
bool sameItemQueued = false; |
| 1228 |
|
| 1229 |
if (indiItem1 && indiItem2) { |
| 1230 |
QSet<COptimizedKPSetIndividualItem*>* possSameIndiItemSet = indiItem1->getPossibleSameInstantiatedItemSet(); |
| 1231 |
if (possSameIndiItemSet) { |
| 1232 |
if (possSameIndiItemSet->contains(indiItem2)) { |
| 1233 |
CRealizationEntailmentQueuedIndividualsSameInstanceTestingItem* incSameInstTestItem = new CRealizationEntailmentQueuedIndividualsSameInstanceTestingItem(indiItem1, indiItem2, procData); |
| 1234 |
procData->incProcessingItemCount(mRealizeSameIndividualsProcessingStep); |
| 1235 |
addEntailmentIndividualsSameInstanceTestingItem(incSameInstTestItem); |
| 1236 |
} |
| 1237 |
} |
| 1238 |
|
| 1239 |
if (sameItemQueued) { |
| 1240 |
procData->setAssociatedRelizationTestingStep(mRealizeSameIndividualsProcessingStep); |
| 1241 |
getRealizeSameIndividualsProcessingStep()->addRequirementProcessingData(procData); |
| 1242 |
return true; |
| 1243 |
} else { |
| 1244 |
return false; |
| 1245 |
} |
| 1246 |
} |
| 1247 |
return false; |
| 1248 |
} |
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::queueRoleFillerInstanceRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, const CIndividualReference& indiSource, CRole* role, bool roleInversed, bool subRoleRealization) { |
| 1258 |
if (role == nullptr) { |
| 1259 |
role = mOntology->getRBox()->getTopObjectRole(); |
| 1260 |
subRoleRealization = true; |
| 1261 |
} |
| 1262 |
bool roleItemQueued = false; |
| 1263 |
|
| 1264 |
COptimizedKPSetIndividualItem* indiSourceItem = getInstanceItem(indiSource, true); |
| 1265 |
CRealizationIndividualInstanceItemReference indiSourceItemRef = CRealizationIndividualInstanceItemReference(indiSource, indiSourceItem); |
| 1266 |
|
| 1267 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = mRedirectedRoleInstancesItemHash.value(role); |
| 1268 |
if (redRoleItem) { |
| 1269 |
COptimizedKPSetRoleInstancesItem* initRoleItem = redRoleItem->getRedirectedItem(); |
| 1270 |
bool inversed = roleInversed^redRoleItem->isInversed(); |
| 1271 |
|
| 1272 |
QList<TRoleItemInversionPair> itemList; |
| 1273 |
QSet<TRoleItemInversionPair> itemSet; |
| 1274 |
itemList.append(TRoleItemInversionPair(initRoleItem, inversed)); |
| 1275 |
itemSet.insert(TRoleItemInversionPair(initRoleItem, inversed)); |
| 1276 |
|
| 1277 |
|
| 1278 |
while (!itemList.isEmpty()) { |
| 1279 |
TRoleItemInversionPair roleItemInvPair = itemList.takeFirst(); |
| 1280 |
COptimizedKPSetRoleInstancesItem* roleItem = roleItemInvPair.first; |
| 1281 |
bool inversed = roleItemInvPair.second; |
| 1282 |
|
| 1283 |
if (indiSourceItem) { |
| 1284 |
//if (!indiSourceItem->hasAllRoleCandidatesInitializedFlag()) { |
| 1285 |
//} else { |
| 1286 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleInstancesHash = indiSourceItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 1287 |
if (knownPossibleInstancesHash) { |
| 1288 |
COptimizedKPSetRoleNeighbourInstancesHashData possNeighbourInstanceData = knownPossibleInstancesHash->value(roleItem); |
| 1289 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = possNeighbourInstanceData.getRoleNeighbourInstancesHash(inversed, false); |
| 1290 |
if (possNeighbourInstanceHash) { |
| 1291 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd; ++itNeighInst) { |
| 1292 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 1293 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 1294 |
if (instanceData && !instanceData->mKnownInstance && instanceData->mPossibleInstance && !instanceData->mTestedInstance) { |
| 1295 |
COptimizedKPSetIndividualItem* destIndiItem = destIndiInstanceDat.mNeighbourIndividualItem; |
| 1296 |
CRealizationIndividualInstanceItemReference indiDestItemRef = CRealizationIndividualInstanceItemReference(destIndiItem->getIndividualReference(), destIndiItem); |
| 1297 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* incRoleInstTestItem = new CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem(indiSourceItemRef, indiDestItemRef, roleItem, inversed, procData); |
| 1298 |
procData->incProcessingItemCount(mRealizeRoleProcessingStep); |
| 1299 |
addEntailmentIndividualsRoleInstanceTestingItem(incRoleInstTestItem); |
| 1300 |
roleItemQueued = true; |
| 1301 |
} |
| 1302 |
} |
| 1303 |
} |
| 1304 |
} |
| 1305 |
//} |
| 1306 |
} |
| 1307 |
if (roleItem->hasComplexRoleData()) { |
| 1308 |
QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* indiComplexRoleDataHash = roleItem->getIndividualIdComplexRoleDataHash(); |
| 1309 |
if (indiComplexRoleDataHash->contains(indiSource.getIndividualID())) { |
| 1310 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = indiComplexRoleDataHash->value(indiSource.getIndividualID()); |
| 1311 |
if (!indiComplexData || !indiComplexData->isInitialized(inversed)) { |
| 1312 |
// TODO: check inverse |
| 1313 |
|
| 1314 |
|
| 1315 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(indiSource.getIndividualID()); |
| 1316 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 1317 |
|
| 1318 |
bool initializationRequired = false; |
| 1319 |
if (roleItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(inversed)->contains(combinedNeigRoleSetLabel)) { |
| 1320 |
initializationRequired = true; |
| 1321 |
} |
| 1322 |
CBackendRepresentativeMemoryLabelCacheItem* combinedExistentailDeterministicRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 1323 |
if (combinedExistentailDeterministicRoleSetLabel && roleItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(inversed)->contains(combinedExistentailDeterministicRoleSetLabel)) { |
| 1324 |
initializationRequired = true; |
| 1325 |
} |
| 1326 |
CBackendRepresentativeMemoryLabelCacheItem* combinedExistentailNonDeterministicRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 1327 |
if (combinedExistentailNonDeterministicRoleSetLabel && roleItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(inversed)->contains(combinedExistentailNonDeterministicRoleSetLabel)) { |
| 1328 |
initializationRequired = true; |
| 1329 |
} |
| 1330 |
|
| 1331 |
if (initializationRequired) { |
| 1332 |
if (inversed) { |
| 1333 |
addRolePredecessorInstanceIndividualItemPairToInitializeCandidates(indiSourceItemRef, roleItem); |
| 1334 |
} else { |
| 1335 |
addRoleSuccessorInstanceIndividualItemPairToInitializeCandidates(indiSourceItemRef, roleItem); |
| 1336 |
} |
| 1337 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* incRoleInstTestItem = new CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem(indiSourceItemRef, CRealizationIndividualInstanceItemReference(), roleItem, inversed, procData); |
| 1338 |
procData->incProcessingItemCount(mRealizeRoleProcessingStep); |
| 1339 |
addEntailmentIndividualsRoleInstanceTestingItem(incRoleInstTestItem); |
| 1340 |
roleItemQueued = true; |
| 1341 |
} else { |
| 1342 |
// nothing to do, individual has no link with a starter role (it may have some links for the queried role, but they are already handled with other (iterator) data structures |
| 1343 |
if (!indiComplexData) { |
| 1344 |
indiComplexData = roleItem->getIndividualIdComplexRoleData(indiSource.getIndividualID(), true); |
| 1345 |
} |
| 1346 |
indiComplexData->setInitializing(inversed, true); |
| 1347 |
indiComplexData->setInitialized(inversed, true); |
| 1348 |
} |
| 1349 |
|
| 1350 |
} else { |
| 1351 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 1352 |
|
| 1353 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(inversed, false); |
| 1354 |
if (possNeighbourInstanceHash) { |
| 1355 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd; ++itNeighInst) { |
| 1356 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 1357 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 1358 |
if (instanceData && !instanceData->mKnownInstance && instanceData->mPossibleInstance && !instanceData->mTestedInstance) { |
| 1359 |
CRealizationIndividualInstanceItemReference indiDestItemRef = getInstanceItemReference(itNeighInst.key(), false); |
| 1360 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* incRoleInstTestItem = new CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem(indiSourceItemRef, indiDestItemRef, roleItem, inversed, procData); |
| 1361 |
procData->incProcessingItemCount(mRealizeRoleProcessingStep); |
| 1362 |
addEntailmentIndividualsRoleInstanceTestingItem(incRoleInstTestItem); |
| 1363 |
roleItemQueued = true; |
| 1364 |
} |
| 1365 |
} |
| 1366 |
} |
| 1367 |
|
| 1368 |
} |
| 1369 |
} |
| 1370 |
} |
| 1371 |
|
| 1372 |
if (subRoleRealization) { |
| 1373 |
QList<TRoleItemInversionPair>* succItemList = roleItem->getSuccessorItemList(); |
| 1374 |
for (QList<TRoleItemInversionPair>::const_iterator it = succItemList->constBegin(), itEnd = succItemList->constEnd(); it != itEnd; ++it) { |
| 1375 |
TRoleItemInversionPair succItemPair(*it); |
| 1376 |
TRoleItemInversionPair succInvItemPair(succItemPair.first, succItemPair.second^inversed); |
| 1377 |
if (!itemSet.contains(succInvItemPair)) { |
| 1378 |
itemSet.insert(succInvItemPair); |
| 1379 |
itemList.append(succInvItemPair); |
| 1380 |
} |
| 1381 |
} |
| 1382 |
} |
| 1383 |
|
| 1384 |
} |
| 1385 |
} |
| 1386 |
|
| 1387 |
if (roleItemQueued) { |
| 1388 |
procData->setAssociatedRelizationTestingStep(mRealizeRoleProcessingStep); |
| 1389 |
getRealizeRoleProcessingStep()->addRequirementProcessingData(procData); |
| 1390 |
return true; |
| 1391 |
} else { |
| 1392 |
return false; |
| 1393 |
} |
| 1394 |
|
| 1395 |
} |
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::queueRoleInstanceRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, const CIndividualReference& indiSource, const CIndividualReference& indiDestination, CRole* role, bool roleInversed, bool subRoleRealization) { |
| 1402 |
if (role == nullptr) { |
| 1403 |
role = mOntology->getRBox()->getTopObjectRole(); |
| 1404 |
subRoleRealization = true; |
| 1405 |
} |
| 1406 |
|
| 1407 |
COptimizedKPSetIndividualItem* indiSourceItem = getInstanceItem(indiSource, true); |
| 1408 |
COptimizedKPSetIndividualItem* indiDestItem = getInstanceItem(indiDestination, true); |
| 1409 |
|
| 1410 |
CRealizationIndividualInstanceItemReference indiSourceItemRef = CRealizationIndividualInstanceItemReference(indiSource, indiSourceItem); |
| 1411 |
CRealizationIndividualInstanceItemReference indiDestItemRef = CRealizationIndividualInstanceItemReference(indiDestination, indiDestItem); |
| 1412 |
|
| 1413 |
bool roleItemQueued = false; |
| 1414 |
|
| 1415 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = mRedirectedRoleInstancesItemHash.value(role); |
| 1416 |
COptimizedKPSetRoleInstancesItem* initRoleItem = redRoleItem->getRedirectedItem(); |
| 1417 |
bool inversed = roleInversed^redRoleItem->isInversed(); |
| 1418 |
|
| 1419 |
|
| 1420 |
QList<TRoleItemInversionPair> itemList; |
| 1421 |
QSet<TRoleItemInversionPair> itemSet; |
| 1422 |
itemList.append(TRoleItemInversionPair(initRoleItem, inversed)); |
| 1423 |
itemSet.insert(TRoleItemInversionPair(initRoleItem, inversed)); |
| 1424 |
|
| 1425 |
|
| 1426 |
while (!itemList.isEmpty()) { |
| 1427 |
TRoleItemInversionPair roleItemInvPair = itemList.takeFirst(); |
| 1428 |
COptimizedKPSetRoleInstancesItem* roleItem = roleItemInvPair.first; |
| 1429 |
bool inversed = roleItemInvPair.second; |
| 1430 |
bool isInstance = false; |
| 1431 |
bool isPossibleInstance = true; |
| 1432 |
bool isInitialized = false; |
| 1433 |
bool hasDirectNeighbourData = false; |
| 1434 |
|
| 1435 |
if (indiSourceItem && indiDestItem) { |
| 1436 |
//if (indiSourceItem->hasAllRoleCandidatesInitializedFlag()) { |
| 1437 |
// isPossibleInstance = false; |
| 1438 |
// isInitialized = true; |
| 1439 |
//} |
| 1440 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleInstancesHash = indiSourceItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 1441 |
if (knownPossibleInstancesHash) { |
| 1442 |
COptimizedKPSetRoleNeighbourInstancesHashData possNeighbourInstanceData = knownPossibleInstancesHash->value(roleItem); |
| 1443 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = possNeighbourInstanceData.getRoleNeighbourInstancesHash(inversed, false); |
| 1444 |
if (possNeighbourInstanceHash) { |
| 1445 |
COptimizedKPSetRoleInstancesData* instanceData = possNeighbourInstanceHash->value(indiDestItem->getIndividualId()).mInstanceItemData; |
| 1446 |
if (instanceData) { |
| 1447 |
isInstance = instanceData->mKnownInstance; |
| 1448 |
isPossibleInstance = isInstance || instanceData->mPossibleInstance && !instanceData->mTestedInstance; |
| 1449 |
hasDirectNeighbourData = true; |
| 1450 |
} |
| 1451 |
} |
| 1452 |
} |
| 1453 |
} |
| 1454 |
if (!hasDirectNeighbourData && roleItem->hasComplexRoleData()) { |
| 1455 |
QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* indiComplexRoleDataHash = roleItem->getIndividualIdComplexRoleDataHash(); |
| 1456 |
if (indiComplexRoleDataHash->contains(indiSource.getIndividualID())) { |
| 1457 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = indiComplexRoleDataHash->value(indiSource.getIndividualID()); |
| 1458 |
if (indiComplexData && indiComplexData->isInitialized(inversed)) { |
| 1459 |
|
| 1460 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 1461 |
COptimizedKPSetRoleInstancesData* instanceData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstanceItemData(inversed, indiDestination.getIndividualID(), false); |
| 1462 |
if (instanceData) { |
| 1463 |
isInstance = instanceData->mKnownInstance; |
| 1464 |
isPossibleInstance = isInstance || instanceData->mPossibleInstance && !instanceData->mTestedInstance; |
| 1465 |
} |
| 1466 |
|
| 1467 |
} else if (!indiComplexData || !indiComplexData->isInitializing(inversed)) { |
| 1468 |
// TODO: do initialization only for the given role |
| 1469 |
addRoleInstanceIndividualItemToInitializeCandidates(indiSourceItemRef); |
| 1470 |
} |
| 1471 |
} |
| 1472 |
} |
| 1473 |
|
| 1474 |
if (!isInstance && isPossibleInstance) { |
| 1475 |
CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* incRoleInstTestItem = new CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem(indiSourceItemRef, indiDestItemRef, roleItem, inversed, procData); |
| 1476 |
procData->incProcessingItemCount(mRealizeRoleProcessingStep); |
| 1477 |
addEntailmentIndividualsRoleInstanceTestingItem(incRoleInstTestItem); |
| 1478 |
roleItemQueued = true; |
| 1479 |
} |
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
if (subRoleRealization) { |
| 1484 |
QList<TRoleItemInversionPair>* succItemList = roleItem->getSuccessorItemList(); |
| 1485 |
for (QList<TRoleItemInversionPair>::const_iterator it = succItemList->constBegin(), itEnd = succItemList->constEnd(); it != itEnd; ++it) { |
| 1486 |
TRoleItemInversionPair succItemPair(*it); |
| 1487 |
TRoleItemInversionPair succInvItemPair(succItemPair.first, succItemPair.second^inversed); |
| 1488 |
if (!itemSet.contains(succInvItemPair)) { |
| 1489 |
itemSet.insert(succInvItemPair); |
| 1490 |
itemList.append(succInvItemPair); |
| 1491 |
} |
| 1492 |
} |
| 1493 |
} |
| 1494 |
|
| 1495 |
} |
| 1496 |
|
| 1497 |
if (roleItemQueued) { |
| 1498 |
procData->setAssociatedRelizationTestingStep(mRealizeRoleProcessingStep); |
| 1499 |
getRealizeRoleProcessingStep()->addRequirementProcessingData(procData); |
| 1500 |
return true; |
| 1501 |
} else { |
| 1502 |
return false; |
| 1503 |
} |
| 1504 |
|
| 1505 |
} |
| 1506 |
|
| 1507 |
|
| 1508 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::markIntanceItemForConceptRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, CConcept* concept, bool subconceptRealizationRequired) { |
| 1509 |
if (concept == mOntology->getTBox()->getTopConcept()) { |
| 1510 |
setAllConceptInstancesProcessing(true); |
| 1511 |
} |
| 1512 |
COptimizedKPSetConceptInstancesItem* initialItem = mConceptInstancesItemHash.value(concept); |
| 1513 |
QList<COptimizedKPSetConceptInstancesItem*> itemList; |
| 1514 |
QSet<COptimizedKPSetConceptInstancesItem*> itemSet; |
| 1515 |
itemList.append(initialItem); |
| 1516 |
itemSet.insert(initialItem); |
| 1517 |
bool conceptItemQueued = false; |
| 1518 |
while (!itemList.isEmpty()) { |
| 1519 |
COptimizedKPSetConceptInstancesItem* item = itemList.takeFirst(); |
| 1520 |
if (!item->hasToProcessPossibleInstancesFlag()) { |
| 1521 |
item->setToProcessPossibleInstancesFlag(true); |
| 1522 |
if (procData && item->hasPossibleInstances()) { |
| 1523 |
procData->incProcessingItemCount(mRealizeConceptProcessingStep); |
| 1524 |
item->addRequirementProcessingDataLinker(createRequirementProcessingDataLinker(procData)); |
| 1525 |
conceptItemQueued = true; |
| 1526 |
} |
| 1527 |
addConceptInstanceItemToProcessPossibleInstances(item); |
| 1528 |
if (subconceptRealizationRequired) { |
| 1529 |
QList<COptimizedKPSetConceptInstancesItem*>* succItemList = item->getSuccessorItemList(); |
| 1530 |
for (QList<COptimizedKPSetConceptInstancesItem*>::const_iterator it = succItemList->constBegin(), itEnd = succItemList->constEnd(); it != itEnd; ++it) { |
| 1531 |
COptimizedKPSetConceptInstancesItem* succItem(*it); |
| 1532 |
if (!itemSet.contains(succItem)) { |
| 1533 |
itemSet.insert(succItem); |
| 1534 |
itemList.append(succItem); |
| 1535 |
} |
| 1536 |
} |
| 1537 |
} |
| 1538 |
} |
| 1539 |
} |
| 1540 |
|
| 1541 |
|
| 1542 |
if (conceptItemQueued || isAllConceptInstancesProcessing() && !getRealizeConceptProcessingStep()->isStepFinished()) { |
| 1543 |
if (!conceptItemQueued || isAllConceptInstancesProcessing()) { |
| 1544 |
procData->incProcessingItemCount(mRealizeConceptProcessingStep); |
| 1545 |
} |
| 1546 |
procData->setAssociatedRelizationTestingStep(mRealizeConceptProcessingStep); |
| 1547 |
getRealizeConceptProcessingStep()->addRequirementProcessingData(procData); |
| 1548 |
} |
| 1549 |
|
| 1550 |
return this; |
| 1551 |
} |
| 1552 |
|
| 1553 |
|
| 1554 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::markInstantiatedItemForSameIndividualsRealization(COntologyRealizingDynamicRequirmentProcessingData* procData, const CIndividualReference& indi) { |
| 1555 |
bool itemQueued = false; |
| 1556 |
if (indi.isNonEmpty()) { |
| 1557 |
COptimizedKPSetIndividualItem* indiItem = (COptimizedKPSetIndividualItem*)getInstanceItem(indi, true); |
| 1558 |
if (indiItem) { |
| 1559 |
if (!indiItem->hasToProcessPossibleSameIndividualsFlag()) { |
| 1560 |
indiItem->setToProcessPossibleSameIndividualsFlag(true); |
| 1561 |
if (indiItem->hasPossibleSameIndividuals()) { |
| 1562 |
procData->incProcessingItemCount(mRealizeSameIndividualsProcessingStep); |
| 1563 |
indiItem->addRequirementProcessingDataLinker(createRequirementProcessingDataLinker(procData)); |
| 1564 |
itemQueued = true; |
| 1565 |
} |
| 1566 |
addInstantiatedItemToProcessPossibleSameIndividuals(indiItem); |
| 1567 |
} |
| 1568 |
} |
| 1569 |
} else { |
| 1570 |
setAllSameIndividualsProcessing(true); |
| 1571 |
QList<COptimizedKPSetIndividualItem*>* containerList = mIndividualInstantiatedItemHash->getIndividualInstantiatedItemContainerList(); |
| 1572 |
for (COptimizedKPSetIndividualItem*indiItem : *containerList) { |
| 1573 |
if (!indiItem->hasToProcessPossibleSameIndividualsFlag()) { |
| 1574 |
indiItem->setToProcessPossibleSameIndividualsFlag(true); |
| 1575 |
if (procData && indiItem->hasPossibleSameIndividuals()) { |
| 1576 |
procData->incProcessingItemCount(mRealizeSameIndividualsProcessingStep); |
| 1577 |
indiItem->addRequirementProcessingDataLinker(createRequirementProcessingDataLinker(procData)); |
| 1578 |
itemQueued = true; |
| 1579 |
} |
| 1580 |
addInstantiatedItemToProcessPossibleSameIndividuals(indiItem); |
| 1581 |
} |
| 1582 |
} |
| 1583 |
} |
| 1584 |
|
| 1585 |
if (itemQueued || isAllSameIndividualsProcessing() && !getRealizeSameIndividualsProcessingStep()->isStepFinished()) { |
| 1586 |
if (!itemQueued || isAllSameIndividualsProcessing()) { |
| 1587 |
procData->incProcessingItemCount(mRealizeSameIndividualsProcessingStep); |
| 1588 |
} |
| 1589 |
procData->setAssociatedRelizationTestingStep(mRealizeSameIndividualsProcessingStep); |
| 1590 |
getRealizeSameIndividualsProcessingStep()->addRequirementProcessingData(procData); |
| 1591 |
} |
| 1592 |
|
| 1593 |
return this; |
| 1594 |
} |
| 1595 |
|
| 1596 |
CCalculationConfigurationExtension* COptimizedRepresentativeKPSetOntologyRealizingItem::getCalculationConfiguration() { |
| 1597 |
return mCalculationConfig; |
| 1598 |
} |
| 1599 |
|
| 1600 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setRealization(CRealization* realization) { |
| 1601 |
mRealization = realization; |
| 1602 |
return this; |
| 1603 |
} |
| 1604 |
|
| 1605 |
CRealization* COptimizedRepresentativeKPSetOntologyRealizingItem::getRealization() { |
| 1606 |
return mRealization; |
| 1607 |
} |
| 1608 |
|
| 1609 |
|
| 1610 |
|
| 1611 |
CRealizingTestingStep* COptimizedRepresentativeKPSetOntologyRealizingItem::getRealizeConceptProcessingStep() { |
| 1612 |
return mRealizeConceptProcessingStep; |
| 1613 |
} |
| 1614 |
|
| 1615 |
|
| 1616 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRealizeConceptStepFinished() { |
| 1617 |
return mRealizeConceptProcessingStep->isStepFinished(); |
| 1618 |
} |
| 1619 |
|
| 1620 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRealizeConceptStepRequired() { |
| 1621 |
return mRealizeConceptProcessingStep->hasRequirements(); |
| 1622 |
} |
| 1623 |
|
| 1624 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::areRealizeConceptStepProcessingRequirementSatisfied() { |
| 1625 |
return mRealizeConceptProcessingStep->areStepProcessingRequirementSatisfied(); |
| 1626 |
} |
| 1627 |
|
| 1628 |
|
| 1629 |
CRealizingTestingStep* COptimizedRepresentativeKPSetOntologyRealizingItem::getInitRealizeProcessingStep() { |
| 1630 |
return mInitRealizeProcessingStep; |
| 1631 |
} |
| 1632 |
|
| 1633 |
|
| 1634 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isInitRealizeStepFinished() { |
| 1635 |
return mInitRealizeProcessingStep->isStepFinished(); |
| 1636 |
} |
| 1637 |
|
| 1638 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isInitRealizeStepRequired() { |
| 1639 |
return mInitRealizeProcessingStep->hasRequirements(); |
| 1640 |
} |
| 1641 |
|
| 1642 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::areInitRealizeStepProcessingRequirementSatisfied() { |
| 1643 |
return mInitRealizeProcessingStep->areStepProcessingRequirementSatisfied(); |
| 1644 |
} |
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
CRealizingTestingStep* COptimizedRepresentativeKPSetOntologyRealizingItem::getRealizeRoleProcessingStep() { |
| 1649 |
return mRealizeRoleProcessingStep; |
| 1650 |
} |
| 1651 |
|
| 1652 |
|
| 1653 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRealizeRoleStepFinished() { |
| 1654 |
return mRealizeRoleProcessingStep->isStepFinished(); |
| 1655 |
} |
| 1656 |
|
| 1657 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRealizeRoleStepRequired() { |
| 1658 |
return mRealizeRoleProcessingStep->hasRequirements(); |
| 1659 |
} |
| 1660 |
|
| 1661 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::areRealizeRoleStepProcessingRequirementSatisfied() { |
| 1662 |
return mRealizeRoleProcessingStep->areStepProcessingRequirementSatisfied(); |
| 1663 |
} |
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
CRealizingTestingStep* COptimizedRepresentativeKPSetOntologyRealizingItem::getRealizeSameIndividualsProcessingStep() { |
| 1670 |
return mRealizeSameIndividualsProcessingStep; |
| 1671 |
} |
| 1672 |
|
| 1673 |
|
| 1674 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRealizeSameIndividualsStepFinished() { |
| 1675 |
return mRealizeSameIndividualsProcessingStep->isStepFinished(); |
| 1676 |
} |
| 1677 |
|
| 1678 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRealizeSameIndividualsStepRequired() { |
| 1679 |
return mRealizeSameIndividualsProcessingStep->hasRequirements(); |
| 1680 |
} |
| 1681 |
|
| 1682 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::areRealizeSameIndividualsStepProcessingRequirementSatisfied() { |
| 1683 |
return mRealizeSameIndividualsProcessingStep->areStepProcessingRequirementSatisfied(); |
| 1684 |
} |
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::areAllStepFinished() { |
| 1690 |
for (QList<CRealizingTestingStep*>::const_iterator it = mProcessingSteps.constBegin(), itEnd = mProcessingSteps.constEnd(); it != itEnd; ++it) { |
| 1691 |
if (!(*it)->isStepFinished()) { |
| 1692 |
return false; |
| 1693 |
} |
| 1694 |
} |
| 1695 |
return true; |
| 1696 |
} |
| 1697 |
|
| 1698 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingProcessingRequirements() { |
| 1699 |
for (QList<CRealizingTestingStep*>::const_iterator it = mProcessingSteps.constBegin(), itEnd = mProcessingSteps.constEnd(); it != itEnd; ++it) { |
| 1700 |
if ((*it)->hasRequirements()) { |
| 1701 |
return true; |
| 1702 |
} |
| 1703 |
} |
| 1704 |
return false; |
| 1705 |
} |
| 1706 |
|
| 1707 |
|
| 1708 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingCandidateConfirmationRoleInstanceItems() { |
| 1709 |
return !mCandidateConfirmationRoleInstancesItemList.isEmpty(); |
| 1710 |
} |
| 1711 |
|
| 1712 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingInitializingRoleInstanceItems() { |
| 1713 |
return !mInitializingRoleInstancesItemList.isEmpty(); |
| 1714 |
} |
| 1715 |
|
| 1716 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingInitializingRoleInstanceIndividualItemReferences() { |
| 1717 |
return !mInitializingRoleInstancesIndividualItemReferenceList.isEmpty(); |
| 1718 |
} |
| 1719 |
|
| 1720 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingInitializingRoleSuccessorInstanceIndividualItemReferencePairs() { |
| 1721 |
return !mInitializingRoleSuccessorInstancesIndividualItemReferencePairList.isEmpty(); |
| 1722 |
} |
| 1723 |
|
| 1724 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingInitializingRolePredeccessorInstanceIndividualItemReferencePairs() { |
| 1725 |
return !mInitializingRolePredecessorInstancesIndividualItemReferencePairList.isEmpty(); |
| 1726 |
} |
| 1727 |
|
| 1728 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingProcessingRoleInstanceItems() { |
| 1729 |
return !mProcessingPossibleRoleInstancesItemList.isEmpty(); |
| 1730 |
} |
| 1731 |
|
| 1732 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingProcessingConceptInstanceItems() { |
| 1733 |
return !mProcessingConceptInstancesItemList.isEmpty(); |
| 1734 |
} |
| 1735 |
|
| 1736 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingProcessingConceptInstanceIndividualItems() { |
| 1737 |
return !mProcessingPossibleConceptInstanceItemList.isEmpty(); |
| 1738 |
} |
| 1739 |
|
| 1740 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasRemainingProcessingSameIndividualsItems() { |
| 1741 |
return !mProcessingSameIndividualsItemList.isEmpty(); |
| 1742 |
} |
| 1743 |
|
| 1744 |
QHash<CHierarchyNode*,COptimizedKPSetConceptInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getHierarchyNodeInstancesItemHash() { |
| 1745 |
return &mHierNodeInstancesItemHash; |
| 1746 |
} |
| 1747 |
|
| 1748 |
QHash<CConcept*,COptimizedKPSetConceptInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getConceptInstancesItemHash() { |
| 1749 |
return &mConceptInstancesItemHash; |
| 1750 |
} |
| 1751 |
|
| 1752 |
|
| 1753 |
QHash<CRole*,COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstancesItemHash() { |
| 1754 |
return &mRoleInstancesItemHash; |
| 1755 |
} |
| 1756 |
|
| 1757 |
|
| 1758 |
QList<COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstancesItemList() { |
| 1759 |
return &mRoleInstancesItemContainer; |
| 1760 |
} |
| 1761 |
|
| 1762 |
|
| 1763 |
QList<COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getComplexRoleInstancesItemList() { |
| 1764 |
return &mComplexRoleInstancesItemContainer; |
| 1765 |
} |
| 1766 |
|
| 1767 |
|
| 1768 |
COptimizedKPSetIndividualInstantiatedItemMultiHash* COptimizedRepresentativeKPSetOntologyRealizingItem::getIndividualInstantiatedItemHash() { |
| 1769 |
return mIndividualInstantiatedItemHash; |
| 1770 |
} |
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
COptimizedKPSetIndividualItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getIndividualInstantiatedItem(CIndividual* individual, bool directCreate) { |
| 1775 |
return getIndividualInstantiatedItem(individual->getIndividualID(), directCreate, individual); |
| 1776 |
} |
| 1777 |
|
| 1778 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasIndividualInstantiatedItem(CIndividual* individual) { |
| 1779 |
return hasIndividualInstantiatedItem(individual->getIndividualID()); |
| 1780 |
} |
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
COptimizedKPSetIndividualItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getIndividualInstantiatedItem(cint64 indiId, bool directCreate, CIndividual* individual) { |
| 1787 |
return mIndividualInstantiatedItemHash->getIndividualInstantiatedItem(indiId, directCreate, individual); |
| 1788 |
} |
| 1789 |
|
| 1790 |
|
| 1791 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasIndividualInstantiatedItem(cint64 indiId) { |
| 1792 |
return mIndividualInstantiatedItemHash->hasIndividualInstantiatedItem(indiId); |
| 1793 |
} |
| 1794 |
|
| 1795 |
|
| 1796 |
QList<COptimizedKPSetConceptInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getProcessingPossibleConceptInstancesItemList() { |
| 1797 |
return &mProcessingConceptInstancesItemList; |
| 1798 |
} |
| 1799 |
|
| 1800 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addPossibleConceptInstancesIndividualItem(COptimizedKPSetIndividualItem* indiItem) { |
| 1801 |
mProcessingPossibleConceptInstanceItemList.append(indiItem); |
| 1802 |
return this; |
| 1803 |
} |
| 1804 |
|
| 1805 |
QList<COptimizedKPSetIndividualItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getPossibleConceptInstancesIndividualItemList() { |
| 1806 |
return &mProcessingPossibleConceptInstanceItemList; |
| 1807 |
} |
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
QList<COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getProcessingPossibleRoleInstancesItemList() { |
| 1812 |
return &mProcessingPossibleRoleInstancesItemList; |
| 1813 |
} |
| 1814 |
|
| 1815 |
QList<COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getInitializingRoleInstancesItemList() { |
| 1816 |
return &mInitializingRoleInstancesItemList; |
| 1817 |
} |
| 1818 |
|
| 1819 |
|
| 1820 |
QList<COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getCandidateConfirmationRoleInstancesItemList() { |
| 1821 |
return &mCandidateConfirmationRoleInstancesItemList; |
| 1822 |
} |
| 1823 |
|
| 1824 |
QList<CRealizationIndividualInstanceItemReference>* COptimizedRepresentativeKPSetOntologyRealizingItem::getInitializingRoleInstancesIndividualItemReferenceList() { |
| 1825 |
return &mInitializingRoleInstancesIndividualItemReferenceList; |
| 1826 |
} |
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
QList<QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*>>* COptimizedRepresentativeKPSetOntologyRealizingItem::getInitializingRoleSuccessorInstancesIndividualItemReferencePairList() { |
| 1831 |
return &mInitializingRoleSuccessorInstancesIndividualItemReferencePairList; |
| 1832 |
} |
| 1833 |
|
| 1834 |
|
| 1835 |
QList<QPair<CRealizationIndividualInstanceItemReference, COptimizedKPSetRoleInstancesItem*>>* COptimizedRepresentativeKPSetOntologyRealizingItem::getInitializingRolePredecessorInstancesIndividualItemReferencePairList() { |
| 1836 |
return &mInitializingRolePredecessorInstancesIndividualItemReferencePairList; |
| 1837 |
} |
| 1838 |
|
| 1839 |
|
| 1840 |
QList<COptimizedKPSetIndividualItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getProcessingPossibleSameIndividualsItemList() { |
| 1841 |
return &mProcessingSameIndividualsItemList; |
| 1842 |
} |
| 1843 |
|
| 1844 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestedPossibleConceptInstancesCount() { |
| 1845 |
return mTestedPossibleConceptInstancesCount; |
| 1846 |
} |
| 1847 |
|
| 1848 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getOpenPossibleConceptInstancesCount() { |
| 1849 |
return mOpenPossibleConceptInstancesCount; |
| 1850 |
} |
| 1851 |
|
| 1852 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestedPossibleConceptInstancesCount(cint64 incCount) { |
| 1853 |
mTestedPossibleConceptInstancesCount += incCount; |
| 1854 |
return this; |
| 1855 |
} |
| 1856 |
|
| 1857 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incOpenPossibleConceptInstancesCount(cint64 incCount) { |
| 1858 |
mOpenPossibleConceptInstancesCount += incCount; |
| 1859 |
return this; |
| 1860 |
} |
| 1861 |
|
| 1862 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestedPossibleConceptInstancesCount(cint64 decCount) { |
| 1863 |
mTestedPossibleConceptInstancesCount -= decCount; |
| 1864 |
return this; |
| 1865 |
} |
| 1866 |
|
| 1867 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decOpenPossibleConceptInstancesCount(cint64 decCount) { |
| 1868 |
mOpenPossibleConceptInstancesCount -= decCount; |
| 1869 |
return this; |
| 1870 |
} |
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
|
| 1877 |
|
| 1878 |
|
| 1879 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestedPossibleSameIndividualsCount() { |
| 1880 |
return mTestedPossibleSameIndividualsCount; |
| 1881 |
} |
| 1882 |
|
| 1883 |
|
| 1884 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getOpenPossibleSameIndividualsCount() { |
| 1885 |
return mOpenPossibleSameIndividualsCount; |
| 1886 |
} |
| 1887 |
|
| 1888 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestedPossibleSameIndividualsCount(cint64 incCount) { |
| 1889 |
mTestedPossibleSameIndividualsCount += incCount; |
| 1890 |
return this; |
| 1891 |
} |
| 1892 |
|
| 1893 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incOpenPossibleSameIndividualsCount(cint64 incCount) { |
| 1894 |
mOpenPossibleSameIndividualsCount += incCount; |
| 1895 |
return this; |
| 1896 |
} |
| 1897 |
|
| 1898 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestedPossibleSameIndividualsCount(cint64 decCount) { |
| 1899 |
mTestedPossibleSameIndividualsCount -= decCount; |
| 1900 |
return this; |
| 1901 |
} |
| 1902 |
|
| 1903 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decOpenPossibleSameIndividualsCount(cint64 decCount) { |
| 1904 |
mOpenPossibleSameIndividualsCount -= decCount; |
| 1905 |
return this; |
| 1906 |
} |
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
|
| 1911 |
|
| 1912 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incProvidedPossibleInstancesMergingIndividualsCount(cint64 incCount) { |
| 1913 |
mProvidedPossibleInstancesMergingIndividualsCount += incCount; |
| 1914 |
return this; |
| 1915 |
} |
| 1916 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getProvidedPossibleInstancesMergingIndividualsCount() { |
| 1917 |
return mProvidedPossibleInstancesMergingIndividualsCount; |
| 1918 |
} |
| 1919 |
|
| 1920 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incProvidedPossibleInstancesMergingsCount(cint64 incCount) { |
| 1921 |
mProvidedPossibleInstancesMergingsCount += incCount; |
| 1922 |
return this; |
| 1923 |
} |
| 1924 |
|
| 1925 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getProvidedPossibleInstancesMergingsCount() { |
| 1926 |
return mProvidedPossibleInstancesMergingsCount; |
| 1927 |
} |
| 1928 |
|
| 1929 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incAttemptedPossibleInstancesMergingsCount(cint64 incCount) { |
| 1930 |
mAttemptedPossibleInstancesMergingsCount += incCount; |
| 1931 |
return this; |
| 1932 |
} |
| 1933 |
|
| 1934 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getAttemptedPossibleInstancesMergingsCount() { |
| 1935 |
return mAttemptedPossibleInstancesMergingsCount; |
| 1936 |
} |
| 1937 |
|
| 1938 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incSucceddedPossibleInstancesMergingsCount(cint64 incCount) { |
| 1939 |
mSucceddedPossibleInstancesMergingsCount += incCount; |
| 1940 |
return this; |
| 1941 |
} |
| 1942 |
|
| 1943 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getSucceddedPossibleInstancesMergingsCount() { |
| 1944 |
return mSucceddedPossibleInstancesMergingsCount; |
| 1945 |
} |
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
|
| 1954 |
|
| 1955 |
|
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incModelMergingsTriedCount(cint64 incCount) { |
| 1961 |
mModelMergingsTriedCount += incCount; |
| 1962 |
return this; |
| 1963 |
} |
| 1964 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getModelMergingsTriedCount() { |
| 1965 |
return mModelMergingsTriedCount; |
| 1966 |
} |
| 1967 |
|
| 1968 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incModelMergingsSucessCount(cint64 incCount) { |
| 1969 |
mModelMergingsSucessCount += incCount; |
| 1970 |
return this; |
| 1971 |
} |
| 1972 |
|
| 1973 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getModelMergingsSucessCount() { |
| 1974 |
return mModelMergingsSucessCount; |
| 1975 |
} |
| 1976 |
|
| 1977 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incModelMergingsInstanceFoundCount(cint64 incCount) { |
| 1978 |
mModelMergingsInstanceFoundCount += incCount; |
| 1979 |
return this; |
| 1980 |
} |
| 1981 |
|
| 1982 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getModelMergingsInstanceFoundCount() { |
| 1983 |
return mModelMergingsInstanceFoundCount; |
| 1984 |
} |
| 1985 |
|
| 1986 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incModelMergingsNonInstanceFoundCount(cint64 incCount) { |
| 1987 |
mModelMergingsNonInstanceFoundCount += incCount; |
| 1988 |
return this; |
| 1989 |
} |
| 1990 |
|
| 1991 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getModelMergingsNonInstanceFoundCount() { |
| 1992 |
return mModelMergingsNonInstanceFoundCount; |
| 1993 |
} |
| 1994 |
|
| 1995 |
|
| 1996 |
QString COptimizedRepresentativeKPSetOntologyRealizingItem::getIndividualName(const CIndividualReference& indiRef, bool abbreviated) { |
| 1997 |
CIndividual* indi = indiRef.getIndividual(); |
| 1998 |
QString individualString; |
| 1999 |
if (!indi) { |
| 2000 |
indi = mOntology->getABox()->getIndividualVector(false)->getData(indiRef.getIndividualID()); |
| 2001 |
} |
| 2002 |
if (indi) { |
| 2003 |
if (abbreviated) { |
| 2004 |
individualString = CAbbreviatedIRIName::getRecentAbbreviatedPrefixWithAbbreviatedIRIName(indi->getIndividualNameLinker()); |
| 2005 |
} |
| 2006 |
if (individualString.isEmpty()) { |
| 2007 |
individualString = CIRIName::getRecentIRIName(indi->getIndividualNameLinker()); |
| 2008 |
} |
| 2009 |
} else { |
| 2010 |
COntologyTriplesAssertionsAccessor* accessor = mOntology->getOntologyTriplesData()->getTripleAssertionAccessor(); |
| 2011 |
if (accessor) { |
| 2012 |
accessor->visitIndividualName(indiRef.getIndividualID(), [&](const QString& indiName)->bool { |
| 2013 |
individualString = indiName; |
| 2014 |
return true; |
| 2015 |
}); |
| 2016 |
} |
| 2017 |
} |
| 2018 |
return individualString; |
| 2019 |
} |
| 2020 |
|
| 2021 |
|
| 2022 |
CRealizationIndividualInstanceItemReference COptimizedRepresentativeKPSetOntologyRealizingItem::getInstanceItemReference(const CIndividualReference& indiRef) { |
| 2023 |
return getInstanceItemReference(indiRef, true); |
| 2024 |
} |
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
CRealizationIndividualInstanceItemReference COptimizedRepresentativeKPSetOntologyRealizingItem::getInstanceItemReference(const CIndividualReference& indiRef, bool correctSameIndividualsMerging) { |
| 2029 |
COptimizedKPSetIndividualItem* indiItem = getInstanceItem(indiRef, correctSameIndividualsMerging); |
| 2030 |
return CRealizationIndividualInstanceItemReference(indiRef, indiItem); |
| 2031 |
} |
| 2032 |
|
| 2033 |
|
| 2034 |
CRealizationIndividualInstanceItemReference COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstanceItemReference(const CIndividualReference& indiRef) { |
| 2035 |
COptimizedKPSetIndividualItem* indiItem = getInstanceItem(indiRef, false); |
| 2036 |
return CRealizationIndividualInstanceItemReference(indiRef, indiItem); |
| 2037 |
} |
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
CRealizationIndividualInstanceItemReference COptimizedRepresentativeKPSetOntologyRealizingItem::getInstanceItemReference(cint64 indiId, bool correctSameIndividualsMerging) { |
| 2042 |
CIndividualReference indiRef = CIndividualReference(mOntology->getABox()->getIndividualVector()->getData(indiId), indiId); |
| 2043 |
return getInstanceItemReference(indiRef, correctSameIndividualsMerging); |
| 2044 |
} |
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
|
| 2049 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isConceptInstance(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CConceptInstantiatedItem* conItem) { |
| 2050 |
CConceptInstanceItem* indiItem = (CConceptInstanceItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 2051 |
COptimizedKPSetConceptInstancesItem* conceptItem = (COptimizedKPSetConceptInstancesItem*)conItem; |
| 2052 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiItem; |
| 2053 |
if (indiItem) { |
| 2054 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = individualItem->getKnownPossibleInstancesHash(); |
| 2055 |
if (knownPossibleInstancesHash) { |
| 2056 |
const COptimizedKPSetConceptInstancesHashData& hashData = knownPossibleInstancesHash->value(conceptItem); |
| 2057 |
COptimizedKPSetConceptInstancesData* instanceItemData = hashData.mInstanceItemData; |
| 2058 |
if (instanceItemData) { |
| 2059 |
return instanceItemData->mKnownInstance; |
| 2060 |
} |
| 2061 |
} |
| 2062 |
} else { |
| 2063 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = mBackendAssocCacheReader->getIndividualAssociatedCacheLabelItem(indiRealItemRef.getIndividualID(), CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 2064 |
if (labelItem) { |
| 2065 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* labelItemData = getRepresentativeCacheConceptSetLabelItemData(labelItem, false); |
| 2066 |
if (labelItemData) { |
| 2067 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData* labelConInstItemData = labelItemData->getInstancesItemData(conceptItem, false); |
| 2068 |
if (labelConInstItemData) { |
| 2069 |
return !labelConInstItemData->hasPossibleInstances(); |
| 2070 |
} |
| 2071 |
} |
| 2072 |
} |
| 2073 |
} |
| 2074 |
return false; |
| 2075 |
} |
| 2076 |
|
| 2077 |
|
| 2078 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresConceptInstanceRealization(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CConceptInstantiatedItem* conItem) { |
| 2079 |
if (!conItem) { |
| 2080 |
return requiresConceptInstanceRealization(indiRealItemRef); |
| 2081 |
} |
| 2082 |
CConceptInstanceItem* indiItem = (CConceptInstanceItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 2083 |
COptimizedKPSetConceptInstancesItem* conceptItem = (COptimizedKPSetConceptInstancesItem*)conItem; |
| 2084 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiItem; |
| 2085 |
if (indiItem) { |
| 2086 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = individualItem->getKnownPossibleInstancesHash(); |
| 2087 |
if (knownPossibleInstancesHash) { |
| 2088 |
const COptimizedKPSetConceptInstancesHashData& hashData = knownPossibleInstancesHash->value(conceptItem); |
| 2089 |
COptimizedKPSetConceptInstancesData* instanceItemData = hashData.mInstanceItemData; |
| 2090 |
if (instanceItemData) { |
| 2091 |
if (!instanceItemData->mKnownInstance && instanceItemData->mPossibleInstance && instanceItemData->mTestedInstance) { |
| 2092 |
return true; |
| 2093 |
} |
| 2094 |
} |
| 2095 |
} |
| 2096 |
} else { |
| 2097 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = mBackendAssocCacheReader->getIndividualAssociatedCacheLabelItem(indiRealItemRef.getIndividualID(), CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 2098 |
if (labelItem) { |
| 2099 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* labelItemData = getRepresentativeCacheConceptSetLabelItemData(labelItem, false); |
| 2100 |
if (labelItemData) { |
| 2101 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData* labelConInstItemData = labelItemData->getInstancesItemData(conceptItem, false); |
| 2102 |
if (labelConInstItemData) { |
| 2103 |
return labelConInstItemData->hasPossibleInstances(); |
| 2104 |
} |
| 2105 |
} |
| 2106 |
} |
| 2107 |
} |
| 2108 |
return false; |
| 2109 |
} |
| 2110 |
|
| 2111 |
|
| 2112 |
|
| 2113 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresConceptInstanceRealization(const CRealizationIndividualInstanceItemReference& indiRealItemRef) { |
| 2114 |
CConceptInstanceItem* indiItem = (CConceptInstanceItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 2115 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiItem; |
| 2116 |
if (indiItem) { |
| 2117 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = individualItem->getKnownPossibleInstancesHash(); |
| 2118 |
for (QHash<COptimizedKPSetConceptInstancesItem*, COptimizedKPSetConceptInstancesHashData>::const_iterator it = knownPossibleInstancesHash->constBegin(), itEnd = knownPossibleInstancesHash->constEnd(); it != itEnd; ++it) { |
| 2119 |
const COptimizedKPSetConceptInstancesHashData& hashData = it.value(); |
| 2120 |
COptimizedKPSetConceptInstancesData* instanceItemData = hashData.mInstanceItemData; |
| 2121 |
if (instanceItemData) { |
| 2122 |
if (!instanceItemData->mKnownInstance && instanceItemData->mPossibleInstance && instanceItemData->mTestedInstance) { |
| 2123 |
return true; |
| 2124 |
} |
| 2125 |
} |
| 2126 |
} |
| 2127 |
} else { |
| 2128 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = mBackendAssocCacheReader->getIndividualAssociatedCacheLabelItem(indiRealItemRef.getIndividualID(), CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 2129 |
if (labelItem) { |
| 2130 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* labelItemData = getRepresentativeCacheConceptSetLabelItemData(labelItem, false); |
| 2131 |
if (labelItemData) { |
| 2132 |
QHash<COptimizedKPSetConceptInstancesItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*>* possInstHash = labelItemData->getInstancesItemDataHash(); |
| 2133 |
for (QHash<COptimizedKPSetConceptInstancesItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*>::const_iterator it = possInstHash->constBegin(), itEnd = possInstHash->constEnd(); it != itEnd; ++it) { |
| 2134 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData* labelConInstItemData = it.value(); |
| 2135 |
if (labelConInstItemData && labelConInstItemData->hasPossibleInstances()) { |
| 2136 |
return true; |
| 2137 |
} |
| 2138 |
} |
| 2139 |
} |
| 2140 |
} |
| 2141 |
} |
| 2142 |
return false; |
| 2143 |
} |
| 2144 |
|
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitDirectTypes(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CConceptRealizationInstantiatedVisitor* visitor) { |
| 2149 |
return visitTypes(indiRealItemRef, [&](COptimizedKPSetConceptInstancesItem* conceptInstancesItem)->bool { |
| 2150 |
return visitor->visitType(conceptInstancesItem, this); |
| 2151 |
}, true); |
| 2152 |
} |
| 2153 |
|
| 2154 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitAllTypes(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CConceptRealizationInstantiatedVisitor* visitor) { |
| 2155 |
return visitTypes(indiRealItemRef, [&](COptimizedKPSetConceptInstancesItem* conceptInstancesItem)->bool { |
| 2156 |
return visitor->visitType(conceptInstancesItem, this); |
| 2157 |
}, false); |
| 2158 |
} |
| 2159 |
|
| 2160 |
|
| 2161 |
|
| 2162 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitTypes(const CRealizationIndividualInstanceItemReference& indiRealItemRef, function<bool(COptimizedKPSetConceptInstancesItem* conceptInstancesItem)> visitFunc, bool visitDirectTypesOnly) { |
| 2163 |
|
| 2164 |
bool continueVisiting = true; |
| 2165 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 2166 |
if (individualItem) { |
| 2167 |
COptimizedKPSetConceptInstancesHash* knownPossibleInstancesHash = individualItem->getKnownPossibleInstancesHash(); |
| 2168 |
if (knownPossibleInstancesHash) { |
| 2169 |
|
| 2170 |
for (COptimizedKPSetConceptInstancesHash::const_iterator it = knownPossibleInstancesHash->constBegin(), itEnd = knownPossibleInstancesHash->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 2171 |
const COptimizedKPSetConceptInstancesHashData& hashData(it.value()); |
| 2172 |
COptimizedKPSetConceptInstancesData* instanceItemData = hashData.mInstanceItemData; |
| 2173 |
if (instanceItemData->mKnownInstance && (!visitDirectTypesOnly || instanceItemData->mMostSpecific)) { |
| 2174 |
COptimizedKPSetConceptInstancesItem* conInstItem(instanceItemData->mInstanceItem); |
| 2175 |
continueVisiting = visitFunc(conInstItem); |
| 2176 |
} |
| 2177 |
} |
| 2178 |
|
| 2179 |
} |
| 2180 |
} else { |
| 2181 |
CBackendRepresentativeMemoryLabelCacheItem* labelItem = mBackendAssocCacheReader->getIndividualAssociatedCacheLabelItem(indiRealItemRef.getIndividualID(), CBackendRepresentativeMemoryLabelCacheItem::FULL_CONCEPT_SET_LABEL); |
| 2182 |
if (labelItem) { |
| 2183 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* labelItemData = getRepresentativeCacheConceptSetLabelItemData(labelItem, false); |
| 2184 |
if (labelItemData) { |
| 2185 |
QHash<COptimizedKPSetConceptInstancesItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*>* instancesItemDataHash = labelItemData->getInstancesItemDataHash(); |
| 2186 |
for (QHash<COptimizedKPSetConceptInstancesItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData*>::const_iterator it = instancesItemDataHash->constBegin(), itEnd = instancesItemDataHash->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 2187 |
COptimizedKPSetConceptInstancesItem* conInstItem = it.key(); |
| 2188 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemInstancesData* conInstItemData = it.value(); |
| 2189 |
if (!conInstItemData->hasPossibleInstances() && (conInstItemData->hasMostSpecificInstances() || !visitDirectTypesOnly)) { |
| 2190 |
continueVisiting = visitFunc(conInstItem); |
| 2191 |
} |
| 2192 |
} |
| 2193 |
|
| 2194 |
} |
| 2195 |
} |
| 2196 |
} |
| 2197 |
return true; |
| 2198 |
} |
| 2199 |
|
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitDirectInstances(CConceptInstantiatedItem* item, CConceptRealizationInstanceVisitor* visitor) { |
| 2204 |
return visitInstances(item, [&](const CRealizationIndividualInstanceItemReference& indiInstItemRef)->bool { |
| 2205 |
return visitor->visitInstance(indiInstItemRef, this); |
| 2206 |
}, true, CRealizationIndividualSorting(CRealizationIndividualSorting::SORT_TYPE_INDIVIDUAL_ID, CRealizationIndividualSorting::SORT_ORDER_NOTHING, CRealizationIndividualSorting::SORT_GROUP_SAME_UNIQUE)); |
| 2207 |
|
| 2208 |
} |
| 2209 |
|
| 2210 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitAllInstances(CConceptInstantiatedItem* item, CConceptRealizationInstanceVisitor* visitor) { |
| 2211 |
return visitInstances(item, [&](const CRealizationIndividualInstanceItemReference& indiInstItemRef)->bool { |
| 2212 |
return visitor->visitInstance(indiInstItemRef, this); |
| 2213 |
}, false, CRealizationIndividualSorting(CRealizationIndividualSorting::SORT_TYPE_INDIVIDUAL_ID, CRealizationIndividualSorting::SORT_ORDER_NOTHING, CRealizationIndividualSorting::SORT_GROUP_SAME_UNIQUE)); |
| 2214 |
} |
| 2215 |
|
| 2216 |
|
| 2217 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitInstances(CConceptInstantiatedItem* item, function<bool(const CRealizationIndividualInstanceItemReference& indiInstItemRef)> visitFunc, bool visitDirectInstancesOnly, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor) { |
| 2218 |
// iterate over all representative cache items as well as the known/possible data and return the individuals (if sorting is used, then return them accordingly) |
| 2219 |
COptimizedKPSetConceptInstancesItem* conceptItem = (COptimizedKPSetConceptInstancesItem*)item; |
| 2220 |
|
| 2221 |
COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator* cacheLabelInstancesIterator = (COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator*)getConceptInstancesIterator(conceptItem->getHierarchyNode()->getOneEquivalentConcept(), visitDirectInstancesOnly, sorting, indiInstItemRefCursor, true); |
| 2222 |
cacheLabelInstancesIterator->begin(); |
| 2223 |
|
| 2224 |
bool continueVisiting = true; |
| 2225 |
while (!cacheLabelInstancesIterator->atEnd() && continueVisiting) { |
| 2226 |
continueVisiting = visitFunc(cacheLabelInstancesIterator->currentIndividualInstanceItemReference()); |
| 2227 |
cacheLabelInstancesIterator->moveNext(); |
| 2228 |
} |
| 2229 |
|
| 2230 |
delete cacheLabelInstancesIterator; |
| 2231 |
|
| 2232 |
return true; |
| 2233 |
} |
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getConceptInstancesIterator(CConcept* concept, bool onlyDirect, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2238 |
|
| 2239 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2240 |
COptimizedKPSetConceptInstancesItem* conceptItem = (COptimizedKPSetConceptInstancesItem*)getInstantiatedItem(concept); |
| 2241 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> knownCacheItemList; |
| 2242 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> possibleCacheItemList; |
| 2243 |
if (!onlyDirect) { |
| 2244 |
knownCacheItemList = *conceptItem->getKnownInstancesLabelCacheItemList(); |
| 2245 |
possibleCacheItemList = *conceptItem->getPossibleInstancesLabelCacheItemList(); |
| 2246 |
} else { |
| 2247 |
knownCacheItemList = *conceptItem->getKnownMostSpecificInstancesLabelCacheItemList(); |
| 2248 |
possibleCacheItemList = *conceptItem->getPossibleMostSpecificInstancesLabelCacheItemList(); |
| 2249 |
} |
| 2250 |
COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator* cacheLabelInstancesIterator = new COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator(knownCacheItemList, possibleCacheItemList, mIndividualInstantiatedItemHash, indiVector, conceptItem, onlyDirect, sorting, indiInstItemRefCursor, moveOverCursor, mBackendAssocCacheReader); |
| 2251 |
return cacheLabelInstancesIterator; |
| 2252 |
|
| 2253 |
} |
| 2254 |
|
| 2255 |
|
| 2256 |
|
| 2257 |
|
| 2258 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::getPreferredRolePropagationDirection(CRole* role, bool& inversedPreferred) { |
| 2259 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 2260 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 2261 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 2262 |
bool itemInversed = redRoleItem->isInversed(); |
| 2263 |
|
| 2264 |
if (!roleInstItem->hasPropagationDirectionDetermined()) { |
| 2265 |
cint64 instanceCount = 0; |
| 2266 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeighbourRoleSetLabelDataHash = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(false); |
| 2267 |
for (COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash::const_iterator it = combinedNeighbourRoleSetLabelDataHash->constBegin(), itEnd = combinedNeighbourRoleSetLabelDataHash->constEnd(); it != itEnd; ++it) { |
| 2268 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleSetLabel = it.key(); |
| 2269 |
instanceCount += combinedNeighbourRoleSetLabel->getIndividualAssociationCount(); |
| 2270 |
} |
| 2271 |
|
| 2272 |
|
| 2273 |
cint64 inverseInstanceCount = 0; |
| 2274 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* inversedCombinedNeighbourRoleSetLabelDataHash = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(true); |
| 2275 |
for (COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash::const_iterator it = inversedCombinedNeighbourRoleSetLabelDataHash->constBegin(), itEnd = inversedCombinedNeighbourRoleSetLabelDataHash->constEnd(); it != itEnd; ++it) { |
| 2276 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleSetLabel = it.key(); |
| 2277 |
inverseInstanceCount += combinedNeighbourRoleSetLabel->getIndividualAssociationCount(); |
| 2278 |
} |
| 2279 |
|
| 2280 |
if (instanceCount >= inverseInstanceCount * 1.3) { |
| 2281 |
roleInstItem->setPreferredPropagationDirection(COptimizedKPSetRoleInstancesItem::STRAIGHT); |
| 2282 |
} else if (inverseInstanceCount >= instanceCount * 1.3) { |
| 2283 |
roleInstItem->setPreferredPropagationDirection(COptimizedKPSetRoleInstancesItem::INVERSE); |
| 2284 |
} else { |
| 2285 |
roleInstItem->setPreferredPropagationDirection(COptimizedKPSetRoleInstancesItem::NONE); |
| 2286 |
} |
| 2287 |
roleInstItem->setPropagationDirectionDetermined(true); |
| 2288 |
} |
| 2289 |
|
| 2290 |
|
| 2291 |
COptimizedKPSetRoleInstancesItem::RolePreferredPropagationDirection preferredPropagationDirection = roleInstItem->getPreferredPropagationDirection(); |
| 2292 |
if (preferredPropagationDirection == COptimizedKPSetRoleInstancesItem::NONE) { |
| 2293 |
return false; |
| 2294 |
} |
| 2295 |
|
| 2296 |
COptimizedKPSetRoleInstancesItem::RolePreferredPropagationDirection compDirection = COptimizedKPSetRoleInstancesItem::STRAIGHT; |
| 2297 |
if (itemInversed) { |
| 2298 |
compDirection = COptimizedKPSetRoleInstancesItem::INVERSE; |
| 2299 |
} |
| 2300 |
if (preferredPropagationDirection == compDirection) { |
| 2301 |
inversedPreferred = false; |
| 2302 |
} else { |
| 2303 |
inversedPreferred = true; |
| 2304 |
} |
| 2305 |
|
| 2306 |
return true; |
| 2307 |
|
| 2308 |
|
| 2309 |
} |
| 2310 |
|
| 2311 |
|
| 2312 |
|
| 2313 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleNeighbouringInstancesIterator(CRole* role, bool inversed, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2314 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2315 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 2316 |
|
| 2317 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 2318 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 2319 |
bool itemInversed = redRoleItem->isInversed() ^ inversed; |
| 2320 |
|
| 2321 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> possibleAndCandidateLabelSet; |
| 2322 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> knownLabelSet; |
| 2323 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* possibleExtLabelSet = roleInstItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(itemInversed); |
| 2324 |
if (possibleExtLabelSet) { |
| 2325 |
possibleAndCandidateLabelSet.unite(*possibleExtLabelSet); |
| 2326 |
} |
| 2327 |
|
| 2328 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* possibleNeighbourLabelSet = roleInstItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(itemInversed); |
| 2329 |
if (possibleNeighbourLabelSet) { |
| 2330 |
possibleAndCandidateLabelSet.unite(*possibleNeighbourLabelSet); |
| 2331 |
} |
| 2332 |
|
| 2333 |
|
| 2334 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeighbourRoleSetLabelDataHash = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(itemInversed); |
| 2335 |
for (COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash::const_iterator it = combinedNeighbourRoleSetLabelDataHash->constBegin(), itEnd = combinedNeighbourRoleSetLabelDataHash->constEnd(); it != itEnd; ++it) { |
| 2336 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleSetLabel = it.key(); |
| 2337 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeighbourRoleSetLabelData = it.value(); |
| 2338 |
if (combinedNeighbourRoleSetLabelData->hasPossibleInstancesLabelItems()) { |
| 2339 |
possibleAndCandidateLabelSet.insert(combinedNeighbourRoleSetLabel); |
| 2340 |
} |
| 2341 |
if (combinedNeighbourRoleSetLabelData->hasKnownInstancesLabelItems()) { |
| 2342 |
knownLabelSet.insert(combinedNeighbourRoleSetLabel); |
| 2343 |
} |
| 2344 |
} |
| 2345 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> knownCacheItemList = knownLabelSet.toList(); |
| 2346 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> possibleCacheItemList; |
| 2347 |
for (CBackendRepresentativeMemoryLabelCacheItem* item : possibleAndCandidateLabelSet) { |
| 2348 |
if (!knownLabelSet.contains(item)) { |
| 2349 |
possibleCacheItemList.append(item); |
| 2350 |
} |
| 2351 |
} |
| 2352 |
|
| 2353 |
|
| 2354 |
COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator* cacheLabelInstancesIterator = new COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator(knownCacheItemList, possibleCacheItemList, mIndividualInstantiatedItemHash, indiVector, roleInstItem, itemInversed, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2355 |
return cacheLabelInstancesIterator; |
| 2356 |
} |
| 2357 |
|
| 2358 |
|
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleExistentialInstancesIterator(CRole* role, bool inversed, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2363 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2364 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 2365 |
|
| 2366 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 2367 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 2368 |
bool itemInversed = redRoleItem->isInversed() ^ inversed; |
| 2369 |
|
| 2370 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> knownLabelSet; |
| 2371 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> possibleAndCandidateLabelSet; |
| 2372 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* possibleExtLabelSet = roleInstItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(itemInversed); |
| 2373 |
if (possibleExtLabelSet) { |
| 2374 |
possibleAndCandidateLabelSet.unite(*possibleExtLabelSet); |
| 2375 |
} |
| 2376 |
|
| 2377 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* possibleNeighbourLabelSet = roleInstItem->getComplexStarterCandidateCombinedNeighbourRoleLabelCacheItemSet(itemInversed); |
| 2378 |
if (possibleNeighbourLabelSet) { |
| 2379 |
possibleAndCandidateLabelSet.unite(*possibleNeighbourLabelSet); |
| 2380 |
} |
| 2381 |
|
| 2382 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash* combinedNeighbourRoleSetLabelDataHash = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(itemInversed); |
| 2383 |
for (COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelHash::const_iterator it = combinedNeighbourRoleSetLabelDataHash->constBegin(), itEnd = combinedNeighbourRoleSetLabelDataHash->constEnd(); it != itEnd; ++it) { |
| 2384 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeighbourRoleSetLabel = it.key(); |
| 2385 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* combinedNeighbourRoleSetLabelData = it.value(); |
| 2386 |
if (combinedNeighbourRoleSetLabelData->hasPossibleInstancesLabelItems()) { |
| 2387 |
possibleAndCandidateLabelSet.insert(combinedNeighbourRoleSetLabel); |
| 2388 |
} |
| 2389 |
if (combinedNeighbourRoleSetLabelData->hasKnownInstancesLabelItems()) { |
| 2390 |
knownLabelSet.insert(combinedNeighbourRoleSetLabel); |
| 2391 |
} |
| 2392 |
} |
| 2393 |
|
| 2394 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* existentialRoleLabelCacheItemSet = roleInstItem->getExistentialRoleLabelCacheItemSet(itemInversed); |
| 2395 |
if (existentialRoleLabelCacheItemSet) { |
| 2396 |
possibleAndCandidateLabelSet.unite(*existentialRoleLabelCacheItemSet); |
| 2397 |
} |
| 2398 |
|
| 2399 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> knownCacheItemList = knownLabelSet.toList(); |
| 2400 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> possibleCacheItemList; |
| 2401 |
for (CBackendRepresentativeMemoryLabelCacheItem* item : possibleAndCandidateLabelSet) { |
| 2402 |
if (!knownLabelSet.contains(item)) { |
| 2403 |
possibleCacheItemList.append(item); |
| 2404 |
} |
| 2405 |
} |
| 2406 |
|
| 2407 |
COptimizedRepresentativeKPSetCacheLabelExistentialDataRoleItemIterator* cacheLabelInstancesIterator = new COptimizedRepresentativeKPSetCacheLabelExistentialDataRoleItemIterator(knownCacheItemList, possibleCacheItemList, mIndividualInstantiatedItemHash, indiVector, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2408 |
return cacheLabelInstancesIterator; |
| 2409 |
} |
| 2410 |
|
| 2411 |
|
| 2412 |
|
| 2413 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasExistentiallyLinkedRoleInstances(CRole* role, bool inversed) { |
| 2414 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 2415 |
|
| 2416 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 2417 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 2418 |
bool itemInversed = redRoleItem->isInversed() ^ inversed; |
| 2419 |
|
| 2420 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* possibleExtLabelSet = roleInstItem->getComplexStarterCandidateCombinedExistentialRoleLabelCacheItemSet(itemInversed); |
| 2421 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* existentialRoleLabelCacheItemSet = roleInstItem->getExistentialRoleLabelCacheItemSet(itemInversed); |
| 2422 |
if ((existentialRoleLabelCacheItemSet && !existentialRoleLabelCacheItemSet->isEmpty()) || (possibleExtLabelSet && !possibleExtLabelSet->isEmpty())) { |
| 2423 |
return true; |
| 2424 |
} |
| 2425 |
return false; |
| 2426 |
} |
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleDataInstancesIterator(CRole* role, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2431 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2432 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* dataDetRoleLabelSet = mDataRoleDetCacheLabelItemSetHash.value(role); |
| 2433 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* dataNondetRoleLabelSet = mDataRoleNonDetCacheLabelItemSetHash.value(role); |
| 2434 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> knownCacheItemList; |
| 2435 |
QList<CBackendRepresentativeMemoryLabelCacheItem*> possibleCacheItemList; |
| 2436 |
if (dataDetRoleLabelSet) { |
| 2437 |
knownCacheItemList = dataDetRoleLabelSet->toList(); |
| 2438 |
} |
| 2439 |
if (dataNondetRoleLabelSet) { |
| 2440 |
possibleCacheItemList = dataNondetRoleLabelSet->toList(); |
| 2441 |
} |
| 2442 |
|
| 2443 |
COptimizedRepresentativeKPSetCacheLabelExistentialDataRoleItemIterator* cacheLabelInstancesIterator = new COptimizedRepresentativeKPSetCacheLabelExistentialDataRoleItemIterator(knownCacheItemList, possibleCacheItemList, mIndividualInstantiatedItemHash, indiVector, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2444 |
return cacheLabelInstancesIterator; |
| 2445 |
} |
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasOnlyDeterministicRoleDataInstances(CRole* role) { |
| 2450 |
return !mDataRoleNondeterministicCacheLabelsSet.contains(role); |
| 2451 |
} |
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleFillerInstancesIterator(const CRealizationIndividualInstanceItemReference& indiInstItemRef, CRole* role, bool inversed, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2458 |
|
| 2459 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 2460 |
|
| 2461 |
return getRoleFillerInstancesIterator(indiInstItemRef, roleItem, inversed, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2462 |
} |
| 2463 |
|
| 2464 |
|
| 2465 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleFillerInstancesIterator(const CRealizationIndividualInstanceItemReference& indiInstItemRef, CRoleInstantiatedItem* roleInstancesItem, bool inversed, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2466 |
|
| 2467 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2468 |
|
| 2469 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleInstancesItem; |
| 2470 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 2471 |
bool itemInversed = redRoleItem->isInversed() ^ inversed; |
| 2472 |
|
| 2473 |
CRealizationIndividualInstanceItemReferenceIterator* fillerIterator = nullptr; |
| 2474 |
bool considerSameMergedIndis = sorting.getGrouping() != CRealizationIndividualSorting::SORT_GROUP_SAME_UNIQUE; |
| 2475 |
|
| 2476 |
if (sorting.isNothing()) { |
| 2477 |
fillerIterator = new COptimizedRepresentativeKPSetUnsortedIndividualRoleFillerItemIterator(indiInstItemRef, mBackendAssocCacheReader, roleInstItem, itemInversed, mIndividualInstantiatedItemHash, indiVector, true); |
| 2478 |
} else if (sorting.getType() == CRealizationIndividualSorting::SORT_TYPE_NOTHING && sorting.getGrouping() == CRealizationIndividualSorting::SORT_GROUP_SAME_UNIQUE && !considerSameMergedIndis) { |
| 2479 |
fillerIterator = new COptimizedRepresentativeKPSetUnsortedIndividualRoleFillerItemIterator(indiInstItemRef, mBackendAssocCacheReader, roleInstItem, itemInversed, mIndividualInstantiatedItemHash, indiVector, false); |
| 2480 |
} else { |
| 2481 |
fillerIterator = new COptimizedRepresentativeKPSetIndividualRoleFillerItemIterator(indiInstItemRef, mBackendAssocCacheReader, roleInstItem, itemInversed, mIndividualInstantiatedItemHash, indiVector, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2482 |
} |
| 2483 |
return fillerIterator; |
| 2484 |
} |
| 2485 |
|
| 2486 |
|
| 2487 |
|
| 2488 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getIterationCandidateIndividualIdIterator(const QMap<cint64, IndividualIdCandidateData>& candidateIndiIdsMap, const CRealizationIndividualSorting& sorting, const CRealizationIndividualInstanceItemReference& indiInstItemRefCursor, bool moveOverCursor) { |
| 2489 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2490 |
return new COptimizedRepresentativeKPSetIndividualCandiatesIterator(candidateIndiIdsMap, mBackendAssocCacheReader, mIndividualInstantiatedItemHash, indiVector, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2491 |
} |
| 2492 |
|
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
CRealizationIndividualInstanceItemReferenceIterator* COptimizedRepresentativeKPSetOntologyRealizingItem::getIterationIntersectionIterator(QList<CRealizationIndividualInstanceItemReferenceIterator*> takeIteratorList) { |
| 2497 |
QList<CRealizationIndividualInstanceItemReferenceIterator*> emptyIteratorList; |
| 2498 |
QList<CRealizationIndividualInstanceItemReferenceIterator*> unmergeableIteratorList; |
| 2499 |
QList<COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator*> conceptSetCacheLabelIteratorList; |
| 2500 |
QList<COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator*> roleNeighbouringCacheLabelIteratorList; |
| 2501 |
|
| 2502 |
CIndividualVector* indiVector = mOntology->getABox()->getIndividualVector(false); |
| 2503 |
|
| 2504 |
for (CRealizationIndividualInstanceItemReferenceIterator* iterator : takeIteratorList) { |
| 2505 |
if (!iterator->requiresInitialization() && iterator->atEnd()) { |
| 2506 |
emptyIteratorList.append(iterator); |
| 2507 |
} else { |
| 2508 |
|
| 2509 |
COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator* conceptSetCacheLabelIterator = dynamic_cast<COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator*>(iterator); |
| 2510 |
if (conceptSetCacheLabelIterator) { |
| 2511 |
conceptSetCacheLabelIteratorList.append(conceptSetCacheLabelIterator); |
| 2512 |
} else { |
| 2513 |
COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator* roleNeighbouringCacheLabelIterator = dynamic_cast<COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator*>(iterator); |
| 2514 |
if (roleNeighbouringCacheLabelIterator) { |
| 2515 |
roleNeighbouringCacheLabelIteratorList.append(roleNeighbouringCacheLabelIterator); |
| 2516 |
} else { |
| 2517 |
unmergeableIteratorList.append(iterator); |
| 2518 |
} |
| 2519 |
} |
| 2520 |
} |
| 2521 |
} |
| 2522 |
|
| 2523 |
bool unsatisfiable = false; |
| 2524 |
if (!emptyIteratorList.isEmpty()) { |
| 2525 |
qDeleteAll(takeIteratorList); |
| 2526 |
unmergeableIteratorList.clear(); |
| 2527 |
conceptSetCacheLabelIteratorList.clear(); |
| 2528 |
roleNeighbouringCacheLabelIteratorList.clear(); |
| 2529 |
unsatisfiable = true; |
| 2530 |
} |
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
if (!unsatisfiable) { |
| 2535 |
if (conceptSetCacheLabelIteratorList.size() > 1) { |
| 2536 |
// merge concept set label iterators |
| 2537 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> validKnownLabelSet; |
| 2538 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> validPossibleLabelSet; |
| 2539 |
bool hasValidLabelSets = false; |
| 2540 |
|
| 2541 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> nextValidKnownLabelSet; |
| 2542 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> nextValidPossibleLabelSet; |
| 2543 |
|
| 2544 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, QSet<TConceptInstancesItemMostSpecificFlagPair>> possibleLabelConceptInstancesItemOnlyMostSpecificFlagPairSetHash; |
| 2545 |
QSet<TConceptInstancesItemMostSpecificFlagPair> conceptInstancesItemOnlyMostSpecificFlagPairSet; |
| 2546 |
|
| 2547 |
|
| 2548 |
// at the moment it is just assumed that all have the same values for cursor/sorting/moveOverCursor |
| 2549 |
// TODO: make sure all have the same values for cursor/sorting/moveOverCursor or combine only those that have the same values or determine a new minimal/maximal cursor |
| 2550 |
CRealizationIndividualSorting sorting = conceptSetCacheLabelIteratorList.first()->getSorting(); |
| 2551 |
CRealizationIndividualInstanceItemReference indiInstItemRefCursor = conceptSetCacheLabelIteratorList.first()->getIndividualInstanceItemReferenceCursor(); |
| 2552 |
bool moveOverCursor = conceptSetCacheLabelIteratorList.first()->hasMoveOverCursor(); |
| 2553 |
|
| 2554 |
|
| 2555 |
for (COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator* conceptSetCacheLabelIterator : conceptSetCacheLabelIteratorList) { |
| 2556 |
|
| 2557 |
conceptInstancesItemOnlyMostSpecificFlagPairSet.unite(*conceptSetCacheLabelIterator->getConceptInstancesItemOnlyMostSpecificFlagPairSet()); |
| 2558 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, QSet<TConceptInstancesItemMostSpecificFlagPair>>* possibleLabelConceptInstancesItemMostSpecificPairSetHash = conceptSetCacheLabelIterator->getPossibleLabelConceptInstancesItemOnlyMostSpecificFlagPairSetHash(); |
| 2559 |
for (QHash<CBackendRepresentativeMemoryLabelCacheItem*, QSet<TConceptInstancesItemMostSpecificFlagPair>>::const_iterator it = possibleLabelConceptInstancesItemMostSpecificPairSetHash->constBegin(), itEnd = possibleLabelConceptInstancesItemMostSpecificPairSetHash->constEnd(); it != itEnd; ++it) { |
| 2560 |
QSet<TConceptInstancesItemMostSpecificFlagPair>& instancesItemMostSpecificPairSet = possibleLabelConceptInstancesItemOnlyMostSpecificFlagPairSetHash[it.key()]; |
| 2561 |
instancesItemMostSpecificPairSet.unite(it.value()); |
| 2562 |
} |
| 2563 |
|
| 2564 |
for (CBackendRepresentativeMemoryLabelCacheItem* label : *conceptSetCacheLabelIterator->getKnownInstancesLabelCacheItemList()) { |
| 2565 |
if (!hasValidLabelSets || validKnownLabelSet.contains(label) && !nextValidPossibleLabelSet.contains(label)) { |
| 2566 |
nextValidKnownLabelSet.insert(label); |
| 2567 |
} |
| 2568 |
if (validPossibleLabelSet.contains(label)) { |
| 2569 |
nextValidPossibleLabelSet.insert(label); |
| 2570 |
} |
| 2571 |
} |
| 2572 |
|
| 2573 |
for (CBackendRepresentativeMemoryLabelCacheItem* label : *conceptSetCacheLabelIterator->getPossibleInstancesLabelCacheItemList()) { |
| 2574 |
if (!hasValidLabelSets || validPossibleLabelSet.contains(label)) { |
| 2575 |
nextValidPossibleLabelSet.insert(label); |
| 2576 |
} else if (validKnownLabelSet.contains(label)) { |
| 2577 |
nextValidKnownLabelSet.remove(label); |
| 2578 |
nextValidPossibleLabelSet.insert(label); |
| 2579 |
} |
| 2580 |
} |
| 2581 |
|
| 2582 |
hasValidLabelSets = true; |
| 2583 |
validKnownLabelSet = nextValidKnownLabelSet; |
| 2584 |
validPossibleLabelSet = nextValidPossibleLabelSet; |
| 2585 |
nextValidKnownLabelSet.clear(); |
| 2586 |
nextValidPossibleLabelSet.clear(); |
| 2587 |
} |
| 2588 |
|
| 2589 |
qDeleteAll(conceptSetCacheLabelIteratorList); |
| 2590 |
conceptSetCacheLabelIteratorList.clear(); |
| 2591 |
if (!validKnownLabelSet.isEmpty() || !validPossibleLabelSet.isEmpty()) { |
| 2592 |
COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator* cacheLabelInstancesIterator = new COptimizedRepresentativeKPSetCacheLabelConceptSetItemIterator(validKnownLabelSet.toList(), validPossibleLabelSet.toList(), mIndividualInstantiatedItemHash, indiVector, possibleLabelConceptInstancesItemOnlyMostSpecificFlagPairSetHash, conceptInstancesItemOnlyMostSpecificFlagPairSet, sorting, indiInstItemRefCursor, moveOverCursor, mBackendAssocCacheReader); |
| 2593 |
unmergeableIteratorList.append(cacheLabelInstancesIterator); |
| 2594 |
} else { |
| 2595 |
unsatisfiable = true; |
| 2596 |
} |
| 2597 |
|
| 2598 |
} else if (!conceptSetCacheLabelIteratorList.isEmpty()) { |
| 2599 |
unmergeableIteratorList.append(conceptSetCacheLabelIteratorList.first()); |
| 2600 |
conceptSetCacheLabelIteratorList.clear(); |
| 2601 |
} |
| 2602 |
} |
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
|
| 2607 |
if (!unsatisfiable) { |
| 2608 |
if (roleNeighbouringCacheLabelIteratorList.size() > 1) { |
| 2609 |
// merge concept set label iterators |
| 2610 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> validKnownLabelSet; |
| 2611 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> validPossibleLabelSet; |
| 2612 |
bool hasValidLabelSets = false; |
| 2613 |
|
| 2614 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> nextValidKnownLabelSet; |
| 2615 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*> nextValidPossibleLabelSet; |
| 2616 |
|
| 2617 |
|
| 2618 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, QSet<TRoleInstancesItemInversedFlagPair>> possibleLabelRoleInstancesItemInversedFlagPairSetHash; |
| 2619 |
QSet<TRoleInstancesItemInversedFlagPair> roleInstancesItemInversedFlagPairSet; |
| 2620 |
|
| 2621 |
// at the moment it is just assumed that all have the same values for cursor/sorting/moveOverCursor |
| 2622 |
// TODO: make sure all have the same values for cursor/sorting/moveOverCursor or combine only those that have the same values or determine a new minimal/maximal cursor |
| 2623 |
CRealizationIndividualSorting sorting = roleNeighbouringCacheLabelIteratorList.first()->getSorting(); |
| 2624 |
CRealizationIndividualInstanceItemReference indiInstItemRefCursor = roleNeighbouringCacheLabelIteratorList.first()->getIndividualInstanceItemReferenceCursor(); |
| 2625 |
bool moveOverCursor = roleNeighbouringCacheLabelIteratorList.first()->hasMoveOverCursor(); |
| 2626 |
|
| 2627 |
|
| 2628 |
for (COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator* roleNeighbouringSetCacheLabelIterator : roleNeighbouringCacheLabelIteratorList) { |
| 2629 |
|
| 2630 |
roleInstancesItemInversedFlagPairSet.unite(*roleNeighbouringSetCacheLabelIterator->getRoleInstancesItemInversionPairSet()); |
| 2631 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, QSet<TRoleInstancesItemInversedFlagPair>>* possibleLabelRoleInstancesItemInversionPairSetHash = roleNeighbouringSetCacheLabelIterator->getPossibleLabelRoleInstancesItemInversionPairSetHash(); |
| 2632 |
for (QHash<CBackendRepresentativeMemoryLabelCacheItem*, QSet<TRoleInstancesItemInversedFlagPair>>::const_iterator it = possibleLabelRoleInstancesItemInversionPairSetHash->constBegin(), itEnd = possibleLabelRoleInstancesItemInversionPairSetHash->constEnd(); it != itEnd; ++it) { |
| 2633 |
QSet<TRoleInstancesItemInversedFlagPair>& existSet = possibleLabelRoleInstancesItemInversedFlagPairSetHash[it.key()]; |
| 2634 |
existSet.unite(it.value()); |
| 2635 |
} |
| 2636 |
|
| 2637 |
for (CBackendRepresentativeMemoryLabelCacheItem* label : *roleNeighbouringSetCacheLabelIterator->getKnownInstancesLabelCacheItemList()) { |
| 2638 |
if (!hasValidLabelSets || validKnownLabelSet.contains(label) && !nextValidPossibleLabelSet.contains(label)) { |
| 2639 |
nextValidKnownLabelSet.insert(label); |
| 2640 |
} |
| 2641 |
if (validPossibleLabelSet.contains(label)) { |
| 2642 |
nextValidPossibleLabelSet.insert(label); |
| 2643 |
} |
| 2644 |
} |
| 2645 |
|
| 2646 |
for (CBackendRepresentativeMemoryLabelCacheItem* label : *roleNeighbouringSetCacheLabelIterator->getPossibleInstancesLabelCacheItemList()) { |
| 2647 |
if (!hasValidLabelSets || validPossibleLabelSet.contains(label)) { |
| 2648 |
nextValidPossibleLabelSet.insert(label); |
| 2649 |
} else if (validKnownLabelSet.contains(label)) { |
| 2650 |
nextValidKnownLabelSet.remove(label); |
| 2651 |
nextValidPossibleLabelSet.insert(label); |
| 2652 |
} |
| 2653 |
} |
| 2654 |
|
| 2655 |
|
| 2656 |
hasValidLabelSets = true; |
| 2657 |
validKnownLabelSet = nextValidKnownLabelSet; |
| 2658 |
validPossibleLabelSet = nextValidPossibleLabelSet; |
| 2659 |
nextValidKnownLabelSet.clear(); |
| 2660 |
nextValidPossibleLabelSet.clear(); |
| 2661 |
} |
| 2662 |
|
| 2663 |
qDeleteAll(roleNeighbouringCacheLabelIteratorList); |
| 2664 |
roleNeighbouringCacheLabelIteratorList.clear(); |
| 2665 |
if (!validKnownLabelSet.isEmpty() || !validPossibleLabelSet.isEmpty()) { |
| 2666 |
COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator* cacheLabelInstancesIterator = new COptimizedRepresentativeKPSetCacheLabelRoleNeighbouringItemIterator(validKnownLabelSet.toList(), validPossibleLabelSet.toList(), mIndividualInstantiatedItemHash, indiVector, possibleLabelRoleInstancesItemInversedFlagPairSetHash, roleInstancesItemInversedFlagPairSet, sorting, indiInstItemRefCursor, moveOverCursor); |
| 2667 |
unmergeableIteratorList.append(cacheLabelInstancesIterator); |
| 2668 |
} else { |
| 2669 |
unsatisfiable = true; |
| 2670 |
} |
| 2671 |
|
| 2672 |
} else if (!roleNeighbouringCacheLabelIteratorList.isEmpty()) { |
| 2673 |
unmergeableIteratorList.append(roleNeighbouringCacheLabelIteratorList.first()); |
| 2674 |
roleNeighbouringCacheLabelIteratorList.clear(); |
| 2675 |
} |
| 2676 |
} |
| 2677 |
|
| 2678 |
if (unsatisfiable) { |
| 2679 |
qDeleteAll(unmergeableIteratorList); |
| 2680 |
qDeleteAll(conceptSetCacheLabelIteratorList); |
| 2681 |
qDeleteAll(roleNeighbouringCacheLabelIteratorList); |
| 2682 |
unmergeableIteratorList.clear(); |
| 2683 |
conceptSetCacheLabelIteratorList.clear(); |
| 2684 |
roleNeighbouringCacheLabelIteratorList.clear(); |
| 2685 |
} |
| 2686 |
|
| 2687 |
|
| 2688 |
if (unmergeableIteratorList.size() == 1) { |
| 2689 |
return unmergeableIteratorList.first(); |
| 2690 |
} |
| 2691 |
|
| 2692 |
COptimizedRepresentativeKPSetIntersectionCombinationIterator* combinedIterator = new COptimizedRepresentativeKPSetIntersectionCombinationIterator(unmergeableIteratorList); |
| 2693 |
return combinedIterator; |
| 2694 |
} |
| 2695 |
|
| 2696 |
|
| 2697 |
|
| 2698 |
CSameInstanceItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getSameInstanceItem(const CRealizationIndividualInstanceItemReference& indiRealItemRef) { |
| 2699 |
return indiRealItemRef.getRealizationInstanceItem(); |
| 2700 |
} |
| 2701 |
|
| 2702 |
|
| 2703 |
|
| 2704 |
|
| 2705 |
|
| 2706 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRoleInstance(CRole* role, const CRealizationIndividualInstanceItemReference& sourceIndiRealItemRef, const CRealizationIndividualInstanceItemReference& targetIndiRealItemRef) { |
| 2707 |
CRoleInstantiatedItem* roleItem = getRoleInstantiatedItem(role); |
| 2708 |
|
| 2709 |
COptimizedKPSetRoleInstancesRedirectionItem* redRoleItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 2710 |
COptimizedKPSetRoleInstancesItem* roleInstItem = redRoleItem->getRedirectedItem(); |
| 2711 |
bool inversed = redRoleItem->isInversed(); |
| 2712 |
|
| 2713 |
if (roleInstItem == mTopRoleInstancesItem) { |
| 2714 |
return true; |
| 2715 |
} |
| 2716 |
|
| 2717 |
COptimizedKPSetIndividualItem* sourceIndividualItem = (COptimizedKPSetIndividualItem*)sourceIndiRealItemRef.getRealizationInstanceItem(); |
| 2718 |
if (sourceIndividualItem) { |
| 2719 |
COptimizedKPSetRoleNeighbourInstancesHash* knownPossibleInstancesHash = sourceIndividualItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 2720 |
COptimizedKPSetRoleNeighbourInstancesHashData possNeighbourInstanceData = knownPossibleInstancesHash->value(roleInstItem); |
| 2721 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = possNeighbourInstanceData.getRoleNeighbourInstancesHash(inversed, false); |
| 2722 |
if (possNeighbourInstanceHash) { |
| 2723 |
COptimizedKPSetRoleInstancesData* instanceData = possNeighbourInstanceHash->value(targetIndiRealItemRef.getIndividualID()).mInstanceItemData; |
| 2724 |
if (instanceData) { |
| 2725 |
return instanceData->mKnownInstance; |
| 2726 |
} |
| 2727 |
} |
| 2728 |
// TODO: complex roles |
| 2729 |
} |
| 2730 |
|
| 2731 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(sourceIndiRealItemRef.getIndividualID()); |
| 2732 |
if (indiAssData) { |
| 2733 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 2734 |
|
| 2735 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetLabelHash = indiAssData->getNeighbourRoleSetHash(); |
| 2736 |
if (neighbourRoleSetLabelHash) { |
| 2737 |
CBackendRepresentativeMemoryLabelCacheItem* singleNeigRoleSetLabel = neighbourRoleSetLabelHash->getNeighbourRoleSetLabel(targetIndiRealItemRef.getIndividualID()); |
| 2738 |
|
| 2739 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* roleItemCompNeighLabelData = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(inversed)->value(combinedNeigRoleSetLabel); |
| 2740 |
if (roleItemCompNeighLabelData) { |
| 2741 |
if (roleItemCompNeighLabelData->hasKnownInstancesLabelItem(singleNeigRoleSetLabel)) { |
| 2742 |
return true; |
| 2743 |
} |
| 2744 |
} |
| 2745 |
} |
| 2746 |
|
| 2747 |
} |
| 2748 |
|
| 2749 |
|
| 2750 |
if (roleInstItem->hasComplexRoleData()) { |
| 2751 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = roleInstItem->getIndividualIdComplexRoleData(sourceIndiRealItemRef.getIndividualID(), false); |
| 2752 |
if (indiComplexData) { |
| 2753 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 2754 |
COptimizedKPSetRoleInstancesData* instanceData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstanceItemData(inversed, targetIndiRealItemRef.getIndividualID(), false); |
| 2755 |
if (instanceData) { |
| 2756 |
return instanceData->mKnownInstance; |
| 2757 |
} |
| 2758 |
} |
| 2759 |
} |
| 2760 |
|
| 2761 |
return false; |
| 2762 |
} |
| 2763 |
|
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
|
| 2769 |
|
| 2770 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitIndividuals(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CConceptRealizationIndividualVisitor* visitor) { |
| 2771 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 2772 |
bool continueVisiting = true; |
| 2773 |
if (individualItem) { |
| 2774 |
QSet<CIndividualReference>* individualSet = individualItem->getKnownSameIndividualSet(); |
| 2775 |
for (QSet<CIndividualReference>::const_iterator it = individualSet->constBegin(), itEnd = individualSet->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 2776 |
CIndividualReference individual(*it); |
| 2777 |
continueVisiting = visitor->visitIndividual(individual, this); |
| 2778 |
} |
| 2779 |
} else { |
| 2780 |
CBackendRepresentativeMemoryLabelCacheItem* sameIndilabelItem = mBackendAssocCacheReader->getIndividualAssociatedCacheLabelItem(indiRealItemRef.getIndividualID(), CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 2781 |
if (sameIndilabelItem) { |
| 2782 |
mBackendAssocCacheReader->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, sameIndilabelItem, [&](cint64 indiId)->bool { |
| 2783 |
continueVisiting = visitor->visitIndividual(indiId, this); |
| 2784 |
return continueVisiting; |
| 2785 |
}); |
| 2786 |
} else { |
| 2787 |
continueVisiting = visitor->visitIndividual(indiRealItemRef, this); |
| 2788 |
} |
| 2789 |
} |
| 2790 |
return true; |
| 2791 |
} |
| 2792 |
|
| 2793 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitConcepts(CConceptInstantiatedItem* item, CConceptRealizationConceptVisitor* visitor) { |
| 2794 |
COptimizedKPSetConceptInstancesItem* conceptItem = (COptimizedKPSetConceptInstancesItem*)item; |
| 2795 |
bool continueVisiting = true; |
| 2796 |
CHierarchyNode* hierNode = conceptItem->getHierarchyNode(); |
| 2797 |
if (hierNode) { |
| 2798 |
QList<CConcept*>* conList = hierNode->getEquivalentConceptList(); |
| 2799 |
for (QList<CConcept*>::const_iterator it = conList->constBegin(), itEnd = conList->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 2800 |
CConcept* concept(*it); |
| 2801 |
continueVisiting = visitor->visitConcept(concept,this); |
| 2802 |
} |
| 2803 |
} |
| 2804 |
return true; |
| 2805 |
} |
| 2806 |
|
| 2807 |
|
| 2808 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitHierarchyNode(CConceptInstantiatedItem* item, CConceptRealizationHierarchyNodeVisitor* visitor) { |
| 2809 |
COptimizedKPSetConceptInstancesItem* conceptItem = (COptimizedKPSetConceptInstancesItem*)item; |
| 2810 |
bool continueVisiting = true; |
| 2811 |
CHierarchyNode* hierNode = conceptItem->getHierarchyNode(); |
| 2812 |
if (hierNode) { |
| 2813 |
continueVisiting = visitor->visitHierarchyNode(hierNode, this); |
| 2814 |
} |
| 2815 |
return true; |
| 2816 |
} |
| 2817 |
|
| 2818 |
|
| 2819 |
CSameInstanceItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getSameInstanceItem(CRoleInstanceItem* instanceItem) { |
| 2820 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)instanceItem; |
| 2821 |
return individualItem; |
| 2822 |
} |
| 2823 |
|
| 2824 |
CRoleInstanceItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstanceItem(CSameInstanceItem* instanceItem) { |
| 2825 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)instanceItem; |
| 2826 |
return individualItem; |
| 2827 |
} |
| 2828 |
|
| 2829 |
|
| 2830 |
CRealizationIndividualInstanceItemReference COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstanceItemReference(CSameInstanceItem* instanceItem) { |
| 2831 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)instanceItem; |
| 2832 |
return CRealizationIndividualInstanceItemReference(individualItem->getIndividualReference(), individualItem); |
| 2833 |
} |
| 2834 |
|
| 2835 |
|
| 2836 |
|
| 2837 |
CConceptInstantiatedItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getInstantiatedItem(CConcept* concept) { |
| 2838 |
return mConceptInstancesItemHash.value(concept); |
| 2839 |
} |
| 2840 |
|
| 2841 |
COptimizedKPSetIndividualItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getInstanceItem(const CIndividualReference& indiRef, bool correctSameIndividualsMerging) { |
| 2842 |
COptimizedKPSetIndividualItem* indiRealItem = mIndividualInstantiatedItemHash->getIndividualInstantiatedItem(indiRef.getIndividualID()); |
| 2843 |
if (indiRealItem && correctSameIndividualsMerging && indiRealItem->getItemSameIndividualMerged()) { |
| 2844 |
indiRealItem = indiRealItem->getItemSameIndividualMerged(); |
| 2845 |
} |
| 2846 |
return indiRealItem; |
| 2847 |
} |
| 2848 |
|
| 2849 |
|
| 2850 |
CRoleInstantiatedItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstantiatedItem(CRole* role) { |
| 2851 |
return mRedirectedRoleInstancesItemHash.value(role); |
| 2852 |
} |
| 2853 |
|
| 2854 |
CRoleInstanceItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleInstanceItem(CIndividual* individual) { |
| 2855 |
CRoleInstanceItem* roleItem = mIndividualInstantiatedItemHash->getIndividualInstantiatedItem(individual->getIndividualID()); |
| 2856 |
return roleItem; |
| 2857 |
} |
| 2858 |
|
| 2859 |
|
| 2860 |
|
| 2861 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setPotentiallySameIndividuals(bool potentiallySameIndividuals) { |
| 2862 |
mPotentiallySameIndividuals = potentiallySameIndividuals; |
| 2863 |
return this; |
| 2864 |
} |
| 2865 |
|
| 2866 |
|
| 2867 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasPotentiallySameIndividuals() { |
| 2868 |
return mBackendAssocCacheReader->hasSameIndividualsMergings() || mPotentiallySameIndividuals; |
| 2869 |
} |
| 2870 |
|
| 2871 |
|
| 2872 |
|
| 2873 |
CRealizationIndividualInstanceItemReference COptimizedRepresentativeKPSetOntologyRealizingItem::getSameInstanceItemReference(const CIndividualReference& indiRef) { |
| 2874 |
COptimizedKPSetIndividualItem* indiItem = getInstanceItem(indiRef, false); |
| 2875 |
return CRealizationIndividualInstanceItemReference(indiRef, indiItem); |
| 2876 |
} |
| 2877 |
|
| 2878 |
|
| 2879 |
|
| 2880 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitSameIndividuals(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CSameRealizationIndividualVisitor* visitor) { |
| 2881 |
cint64 indiId = indiRealItemRef.getIndividualID(); |
| 2882 |
bool continueVisiting = visitor->visitIndividual(indiRealItemRef, this); |
| 2883 |
if (continueVisiting) { |
| 2884 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 2885 |
if (individualItem) { |
| 2886 |
QSet<CIndividualReference>* individualSet = individualItem->getKnownSameIndividualSet(); |
| 2887 |
for (QSet<CIndividualReference>::const_iterator it = individualSet->constBegin(), itEnd = individualSet->constEnd(); continueVisiting && it != itEnd; ++it) { |
| 2888 |
CIndividualReference individual(*it); |
| 2889 |
if (individual.getIndividualID() != indiId) { |
| 2890 |
continueVisiting &= visitor->visitIndividual(individual, this); |
| 2891 |
} |
| 2892 |
} |
| 2893 |
return true; |
| 2894 |
} else { |
| 2895 |
|
| 2896 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(indiRealItemRef.getIndividualID()); |
| 2897 |
if (indiAssData) { |
| 2898 |
CBackendRepresentativeMemoryLabelCacheItem* sameIndiSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 2899 |
if (sameIndiSetLabel) { |
| 2900 |
mBackendAssocCacheReader->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, sameIndiSetLabel, [&](cint64 sameIndiId)->bool { |
| 2901 |
if (sameIndiId != indiId) { |
| 2902 |
if (!visitor->visitIndividual(sameIndiId, this)) { |
| 2903 |
return false; |
| 2904 |
} |
| 2905 |
} |
| 2906 |
return true; |
| 2907 |
}); |
| 2908 |
} |
| 2909 |
return true; |
| 2910 |
} |
| 2911 |
} |
| 2912 |
} |
| 2913 |
return false; |
| 2914 |
} |
| 2915 |
|
| 2916 |
|
| 2917 |
|
| 2918 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitSameIndividuals(CSameInstanceItem* item, CSameRealizationIndividualVisitor* visitor) { |
| 2919 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)item; |
| 2920 |
QSet<CIndividualReference>* individualSet = individualItem->getKnownSameIndividualSet(); |
| 2921 |
bool continueVisiting = true; |
| 2922 |
for (QSet<CIndividualReference>::const_iterator it = individualSet->constBegin(), itEnd = individualSet->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 2923 |
CIndividualReference individual(*it); |
| 2924 |
continueVisiting = visitor->visitIndividual(individual,this); |
| 2925 |
} |
| 2926 |
return true; |
| 2927 |
} |
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isSameIndividualsMerged(const CRealizationIndividualInstanceItemReference& indiInstItemRef) { |
| 2933 |
if (indiInstItemRef.getRealizationInstanceItem()) { |
| 2934 |
COptimizedKPSetIndividualItem* indiItem = (COptimizedKPSetIndividualItem*)indiInstItemRef.getRealizationInstanceItem(); |
| 2935 |
if (indiItem->getIndividualId() != indiInstItemRef.getIndividualID() || indiItem->isItemSameIndividualMerged()) { |
| 2936 |
return true; |
| 2937 |
} |
| 2938 |
return false; |
| 2939 |
} else { |
| 2940 |
if (mSameMergedIndisInCache) { |
| 2941 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* neighbourIndiAssData = mBackendAssocCacheReader->getIndividualAssociationData(indiInstItemRef.getIndividualID()); |
| 2942 |
return neighbourIndiAssData->hasRepresentativeSameIndividualMerging(); |
| 2943 |
} else { |
| 2944 |
return false; |
| 2945 |
} |
| 2946 |
} |
| 2947 |
} |
| 2948 |
|
| 2949 |
|
| 2950 |
|
| 2951 |
|
| 2952 |
|
| 2953 |
|
| 2954 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitAllIndividuals(function<bool(const CRealizationIndividualInstanceItemReference& indiInstItemRef)> visitFunc, bool visitSameIndividualMerged) { |
| 2955 |
|
| 2956 |
CBOXSET<CIndividual*>* activeIndiSet = mOntology->getABox()->getActiveIndividualSet(); |
| 2957 |
CIndividualVector* indiVec = mOntology->getABox()->getIndividualVector(false); |
| 2958 |
cint64 indiCount = 0; |
| 2959 |
if (indiVec) { |
| 2960 |
indiCount = indiVec->getItemCount(); |
| 2961 |
} |
| 2962 |
|
| 2963 |
bool visited = false; |
| 2964 |
bool continueVisiting = true; |
| 2965 |
cint64 maxTriplesIndexedIndiId = 0; |
| 2966 |
COntologyTriplesAssertionsAccessor* triplesAccessor = mOntology->getOntologyTriplesData()->getTripleAssertionAccessor(); |
| 2967 |
if (triplesAccessor) { |
| 2968 |
maxTriplesIndexedIndiId = mOntology->getOntologyTriplesData()->getTripleAssertionAccessor()->getMaxIndexedIndividualId(); |
| 2969 |
} |
| 2970 |
if (indiVec) { |
| 2971 |
cint64 indiCount = indiVec->getItemCount(); |
| 2972 |
for (cint64 idx = 0; idx < indiCount && continueVisiting; ++idx) { |
| 2973 |
CIndividual* indi = indiVec->getData(idx); |
| 2974 |
|
| 2975 |
CIndividualReference indiRef; |
| 2976 |
if (indi && activeIndiSet->contains(indi)) { |
| 2977 |
indiRef = CIndividualReference(indi); |
| 2978 |
visited = true; |
| 2979 |
} else if (idx <= maxTriplesIndexedIndiId) { |
| 2980 |
visited = true; |
| 2981 |
indiRef = CIndividualReference(idx); |
| 2982 |
} |
| 2983 |
|
| 2984 |
if (indiRef.isNonEmpty()) { |
| 2985 |
CRealizationIndividualInstanceItemReference indiInstItemRef = getInstanceItemReference(indiRef, false); |
| 2986 |
if (visitSameIndividualMerged || !isSameIndividualsMerged(indiInstItemRef)) { |
| 2987 |
continueVisiting = visitFunc(indiInstItemRef); |
| 2988 |
} |
| 2989 |
} |
| 2990 |
|
| 2991 |
} |
| 2992 |
} |
| 2993 |
return visited; |
| 2994 |
} |
| 2995 |
|
| 2996 |
|
| 2997 |
|
| 2998 |
|
| 2999 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitTargetIndividuals(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleInstantiatedItem* roleItem, CRoleRealizationInstanceVisitor* visitor) { |
| 3000 |
return visitSourceTargetIndividuals(indiRealItemRef, roleItem, false, visitor); |
| 3001 |
} |
| 3002 |
|
| 3003 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitSourceIndividuals(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleInstantiatedItem* roleItem, CRoleRealizationInstanceVisitor* visitor) { |
| 3004 |
return visitSourceTargetIndividuals(indiRealItemRef, roleItem, true, visitor); |
| 3005 |
} |
| 3006 |
|
| 3007 |
|
| 3008 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitSourceTargetIndividuals(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleInstantiatedItem* roleItem, bool source, CRoleRealizationInstanceVisitor* visitor) { |
| 3009 |
COptimizedKPSetRoleInstancesRedirectionItem* roleRedirectionItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 3010 |
COptimizedKPSetRoleInstancesItem* roleInstItem = roleRedirectionItem->getRedirectedItem(); |
| 3011 |
bool roleItemInversed = roleRedirectionItem->isInversed() ^ source; |
| 3012 |
bool continueVisiting = true; |
| 3013 |
if (roleInstItem == mTopRoleInstancesItem) { |
| 3014 |
return visitAllIndividuals([&](const CRealizationIndividualInstanceItemReference& indiInstItemRef)->bool { |
| 3015 |
continueVisiting = visitor->visitRoleInstance(indiInstItemRef, this); |
| 3016 |
return continueVisiting; |
| 3017 |
}, false); |
| 3018 |
} |
| 3019 |
|
| 3020 |
|
| 3021 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 3022 |
if (individualItem) { |
| 3023 |
COptimizedKPSetRoleNeighbourInstancesHash* roleNeighbourHash = individualItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 3024 |
const COptimizedKPSetRoleNeighbourInstancesHashData& roleNeighbourHashData = roleNeighbourHash->value(roleInstItem); |
| 3025 |
COptimizedKPSetRoleInstancesHash* neighbourHash = nullptr; |
| 3026 |
if (roleItemInversed) { |
| 3027 |
neighbourHash = roleNeighbourHashData.mRolePredecessorInstancesHash; |
| 3028 |
} else { |
| 3029 |
neighbourHash = roleNeighbourHashData.mRoleSuccessorInstancesHash; |
| 3030 |
} |
| 3031 |
if (neighbourHash) { |
| 3032 |
for (COptimizedKPSetRoleInstancesHash::const_iterator it = neighbourHash->constBegin(), itEnd = neighbourHash->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 3033 |
const COptimizedKPSetRoleInstancesHashData& neighbourData = it.value(); |
| 3034 |
COptimizedKPSetIndividualItem* neighbourItem = neighbourData.mNeighbourIndividualItem; |
| 3035 |
if (!neighbourItem->isItemSameIndividualMerged()) { |
| 3036 |
COptimizedKPSetRoleInstancesData* roleInstData = neighbourData.mInstanceItemData; |
| 3037 |
if (roleInstData && roleInstData->mKnownInstance) { |
| 3038 |
continueVisiting = visitor->visitRoleInstance(CRealizationIndividualInstanceItemReference(neighbourItem->getIndividualReference(), neighbourItem), this); |
| 3039 |
} |
| 3040 |
} |
| 3041 |
} |
| 3042 |
} |
| 3043 |
} |
| 3044 |
|
| 3045 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(indiRealItemRef.getIndividualID()); |
| 3046 |
if (continueVisiting && indiAssData) { |
| 3047 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 3048 |
CBackendRepresentativeMemoryCacheIndividualRoleSetNeighbourArray* roleSetNeighbourArray = indiAssData->getRoleSetNeighbourArray(); |
| 3049 |
|
| 3050 |
COptimizedKPSetRoleInstancesCombinedNeighbourRoleSetCacheLabelData* roleItemCompNeighLabelData = roleInstItem->getCombinedNeighbourCacheLabelItemDataHash(roleItemInversed)->value(combinedNeigRoleSetLabel); |
| 3051 |
if (roleItemCompNeighLabelData && roleItemCompNeighLabelData->hasKnownInstancesLabelItems()) { |
| 3052 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedKPSetRoleInstancesSingleNeighbourRoleSetCacheLabelData*>* singleNeighLabelDataHash = roleItemCompNeighLabelData->getKnownInstancesLabelItemDataHash(); |
| 3053 |
|
| 3054 |
for (auto it = singleNeighLabelDataHash->constBegin(), itEnd = singleNeighLabelDataHash->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 3055 |
roleSetNeighbourArray->at(it.value()->getLabelArrayIndex()).visitNeighbourIndividualIds([&](cint64 neighbourId)->bool { |
| 3056 |
// check same individual merged |
| 3057 |
CRealizationIndividualInstanceItemReference neighbourIndiItemRef = getInstanceItemReference(neighbourId, false); |
| 3058 |
if (!isSameIndividualsMerged(neighbourIndiItemRef)) { |
| 3059 |
continueVisiting = visitor->visitRoleInstance(neighbourIndiItemRef, this); |
| 3060 |
} |
| 3061 |
return continueVisiting; |
| 3062 |
}); |
| 3063 |
} |
| 3064 |
|
| 3065 |
} |
| 3066 |
} |
| 3067 |
|
| 3068 |
|
| 3069 |
if (continueVisiting && roleInstItem->hasComplexRoleData()) { |
| 3070 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = roleInstItem->getIndividualIdComplexRoleData(indiRealItemRef.getIndividualID(), false); |
| 3071 |
if (indiComplexData) { |
| 3072 |
|
| 3073 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3074 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(roleItemInversed, false); |
| 3075 |
if (possNeighbourInstanceHash) { |
| 3076 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd && continueVisiting; ++itNeighInst) { |
| 3077 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 3078 |
cint64 destIndiId = itNeighInst.key(); |
| 3079 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 3080 |
if (instanceData && instanceData->mKnownInstance) { |
| 3081 |
CRealizationIndividualInstanceItemReference destIndiRef = getInstanceItemReference(destIndiId, false); |
| 3082 |
if (!isSameIndividualsMerged(destIndiRef)) { |
| 3083 |
continueVisiting = visitor->visitRoleInstance(destIndiRef, this); |
| 3084 |
} |
| 3085 |
} |
| 3086 |
} |
| 3087 |
} |
| 3088 |
|
| 3089 |
} |
| 3090 |
} |
| 3091 |
|
| 3092 |
|
| 3093 |
return false; |
| 3094 |
} |
| 3095 |
|
| 3096 |
|
| 3097 |
|
| 3098 |
|
| 3099 |
|
| 3100 |
|
| 3101 |
|
| 3102 |
|
| 3103 |
|
| 3104 |
|
| 3105 |
|
| 3106 |
|
| 3107 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitRoles(CRoleInstantiatedItem* roleItem, CRoleRealizationRoleVisitor* visitor) { |
| 3108 |
|
| 3109 |
COptimizedKPSetRoleInstancesRedirectionItem* roleRedirectionItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 3110 |
COptimizedKPSetRoleInstancesItem* roleInstItem = roleRedirectionItem->getRedirectedItem(); |
| 3111 |
bool roleItemInversed = roleRedirectionItem->isInversed(); |
| 3112 |
bool continueVisiting = true; |
| 3113 |
|
| 3114 |
CRolePropertiesHierarchyNode* hierNode = nullptr; |
| 3115 |
if (!roleItemInversed) { |
| 3116 |
hierNode = roleInstItem->getRoleHierarchyNode(); |
| 3117 |
} else { |
| 3118 |
hierNode = roleInstItem->getInverseRoleHierarchyNode(); |
| 3119 |
} |
| 3120 |
if (hierNode) { |
| 3121 |
QList<CRole*>* roleList = hierNode->getEquivalentRoleList(); |
| 3122 |
for (QList<CRole*>::const_iterator it = roleList->constBegin(), itEnd = roleList->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 3123 |
CRole* role(*it); |
| 3124 |
continueVisiting = visitor->visitRole(role,this); |
| 3125 |
} |
| 3126 |
} |
| 3127 |
return true; |
| 3128 |
} |
| 3129 |
|
| 3130 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitRoleHierarchyNode(CRoleInstantiatedItem* roleItem, CRoleRealizationHierarchyNodeVisitor* visitor) { |
| 3131 |
COptimizedKPSetRoleInstancesRedirectionItem* roleRedirectionItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 3132 |
COptimizedKPSetRoleInstancesItem* roleInstItem = roleRedirectionItem->getRedirectedItem(); |
| 3133 |
bool roleItemInversed = roleRedirectionItem->isInversed(); |
| 3134 |
bool continueVisiting = true; |
| 3135 |
|
| 3136 |
CRolePropertiesHierarchyNode* hierNode = nullptr; |
| 3137 |
if (!roleItemInversed) { |
| 3138 |
hierNode = roleInstItem->getRoleHierarchyNode(); |
| 3139 |
} else { |
| 3140 |
hierNode = roleInstItem->getInverseRoleHierarchyNode(); |
| 3141 |
} |
| 3142 |
if (hierNode) { |
| 3143 |
visitor->visitHierarchyNode(hierNode, this); |
| 3144 |
return true; |
| 3145 |
} else { |
| 3146 |
return false; |
| 3147 |
} |
| 3148 |
} |
| 3149 |
|
| 3150 |
|
| 3151 |
|
| 3152 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitSourceIndividualRoles(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleRealizationInstantiatedVisitor* visitor) { |
| 3153 |
// visit the outgoing roles for the given individual reference |
| 3154 |
return visitSourceTargetIndividualRoles(indiRealItemRef, false, visitor); |
| 3155 |
} |
| 3156 |
|
| 3157 |
|
| 3158 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitTargetIndividualRoles(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleRealizationInstantiatedVisitor* visitor) { |
| 3159 |
// visit the incoming roles for the given individual reference |
| 3160 |
return visitSourceTargetIndividualRoles(indiRealItemRef, true, visitor); |
| 3161 |
} |
| 3162 |
|
| 3163 |
|
| 3164 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitSourceTargetIndividualRoles(const CRealizationIndividualInstanceItemReference& indiRealItemRef, bool target, CRoleRealizationInstantiatedVisitor* visitor) { |
| 3165 |
QSet<CRoleInstantiatedItem*> visitRoleItemSet; |
| 3166 |
collectSourceTargetIndividualRoles(indiRealItemRef, target, true, visitRoleItemSet); |
| 3167 |
bool continueVisiting = true; |
| 3168 |
for (QSet<CRoleInstantiatedItem*>::const_iterator it = visitRoleItemSet.constBegin(), itEnd = visitRoleItemSet.constEnd(); it != itEnd && continueVisiting; ++it) { |
| 3169 |
CRoleInstantiatedItem* roleInstItem(*it); |
| 3170 |
continueVisiting = visitor->visitRoleInstantiated(roleInstItem, this); |
| 3171 |
} |
| 3172 |
return true; |
| 3173 |
} |
| 3174 |
|
| 3175 |
|
| 3176 |
|
| 3177 |
|
| 3178 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::collectSourceTargetIndividualRoles(const CRealizationIndividualInstanceItemReference& indiRealItemRef, bool target, bool collectKnown, QSet<CRoleInstantiatedItem*>& roleSetCollection, QSet<CRoleInstantiatedItem*>* excludeRoleSet) { |
| 3179 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 3180 |
if (individualItem) { |
| 3181 |
COptimizedKPSetRoleNeighbourInstancesHash* roleNeighInsHash = individualItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 3182 |
for (COptimizedKPSetRoleNeighbourInstancesHash::const_iterator it = roleNeighInsHash->constBegin(), itEnd = roleNeighInsHash->constEnd(); it != itEnd; ++it) { |
| 3183 |
COptimizedKPSetRoleInstancesItem* roleItem(it.key()); |
| 3184 |
if (!excludeRoleSet || !excludeRoleSet->contains(roleItem)) { |
| 3185 |
const COptimizedKPSetRoleNeighbourInstancesHashData& neighInstHashData(it.value()); |
| 3186 |
bool hasRoleNeighbour = false; |
| 3187 |
bool hasInvRoleNeighbour = false; |
| 3188 |
|
| 3189 |
COptimizedKPSetRoleInstancesHash* neighbourHash = nullptr; |
| 3190 |
COptimizedKPSetRoleInstancesHash* invNeighbourHash = nullptr; |
| 3191 |
if (!target) { |
| 3192 |
neighbourHash = neighInstHashData.mRoleSuccessorInstancesHash; |
| 3193 |
invNeighbourHash = neighInstHashData.mRolePredecessorInstancesHash; |
| 3194 |
} else { |
| 3195 |
neighbourHash = neighInstHashData.mRolePredecessorInstancesHash; |
| 3196 |
invNeighbourHash = neighInstHashData.mRoleSuccessorInstancesHash; |
| 3197 |
} |
| 3198 |
|
| 3199 |
|
| 3200 |
if (neighbourHash) { |
| 3201 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeigh = neighbourHash->constBegin(), itNeighEnd = neighbourHash->constEnd(); !hasRoleNeighbour && itNeigh != itNeighEnd; ++itNeigh) { |
| 3202 |
const COptimizedKPSetRoleInstancesHashData& roleInstHashData(itNeigh.value()); |
| 3203 |
COptimizedKPSetRoleInstancesData* roleInstData = roleInstHashData.mInstanceItemData; |
| 3204 |
if (collectKnown && roleInstData->mKnownInstance) { |
| 3205 |
hasRoleNeighbour = true; |
| 3206 |
roleSetCollection.insert(roleItem); |
| 3207 |
} else if (!collectKnown && !roleInstData->mKnownInstance && roleInstData->mPossibleInstance && !roleInstData->mTestedInstance) { |
| 3208 |
roleSetCollection.insert(roleItem); |
| 3209 |
} |
| 3210 |
} |
| 3211 |
} |
| 3212 |
CRoleInstantiatedItem* invRoleRedirectedItem = roleItem->getInverseRoleRedirectedItem(); |
| 3213 |
if (invRoleRedirectedItem && invNeighbourHash && roleItem->getInverseRoleHierarchyNode()) { |
| 3214 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeigh = invNeighbourHash->constBegin(), itNeighEnd = invNeighbourHash->constEnd(); !hasInvRoleNeighbour && itNeigh != itNeighEnd; ++itNeigh) { |
| 3215 |
const COptimizedKPSetRoleInstancesHashData& roleInstHashData(itNeigh.value()); |
| 3216 |
COptimizedKPSetRoleInstancesData* roleInstData = roleInstHashData.mInstanceItemData; |
| 3217 |
if (collectKnown && roleInstData->mKnownInstance) { |
| 3218 |
hasInvRoleNeighbour = true; |
| 3219 |
roleSetCollection.insert(invRoleRedirectedItem); |
| 3220 |
} else if (!collectKnown && !roleInstData->mKnownInstance && roleInstData->mPossibleInstance && !roleInstData->mTestedInstance) { |
| 3221 |
roleSetCollection.insert(roleItem); |
| 3222 |
} |
| 3223 |
} |
| 3224 |
} |
| 3225 |
} |
| 3226 |
} |
| 3227 |
} |
| 3228 |
|
| 3229 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(indiRealItemRef.getIndividualID()); |
| 3230 |
if (indiAssData && collectKnown) { |
| 3231 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 3232 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeigRoleSetLabelData = getRepresentativeCacheCombinedNeighbourRoleSetLabelItemData(combinedNeigRoleSetLabel, false); |
| 3233 |
if (combinedNeigRoleSetLabelData) { |
| 3234 |
QSet<COptimizedKPSetRoleInstancesItem*>* roleItemSet = combinedNeigRoleSetLabelData->getKnownInstancesItemSet(false); |
| 3235 |
QSet<COptimizedKPSetRoleInstancesItem*>* invRoleItemSet = combinedNeigRoleSetLabelData->getKnownInstancesItemSet(true); |
| 3236 |
for (COptimizedKPSetRoleInstancesItem* roleItem : *roleItemSet) { |
| 3237 |
if (!excludeRoleSet || !excludeRoleSet->contains(roleItem)) { |
| 3238 |
// inversed = target; |
| 3239 |
if (target) { |
| 3240 |
CRoleInstantiatedItem* invRoleRedirectedItem = roleItem->getInverseRoleRedirectedItem(); |
| 3241 |
if (invRoleRedirectedItem && roleItem->getInverseRoleHierarchyNode()) { |
| 3242 |
roleSetCollection.insert(invRoleRedirectedItem); |
| 3243 |
} |
| 3244 |
} else { |
| 3245 |
roleSetCollection.insert(roleItem); |
| 3246 |
} |
| 3247 |
} |
| 3248 |
} |
| 3249 |
for (COptimizedKPSetRoleInstancesItem* roleItem : *invRoleItemSet) { |
| 3250 |
if (!excludeRoleSet || !excludeRoleSet->contains(roleItem)) { |
| 3251 |
// inversed = !target; |
| 3252 |
if (!target) { |
| 3253 |
CRoleInstantiatedItem* invRoleRedirectedItem = roleItem->getInverseRoleRedirectedItem(); |
| 3254 |
if (invRoleRedirectedItem && roleItem->getInverseRoleHierarchyNode()) { |
| 3255 |
roleSetCollection.insert(invRoleRedirectedItem); |
| 3256 |
} |
| 3257 |
} else { |
| 3258 |
roleSetCollection.insert(roleItem); |
| 3259 |
} |
| 3260 |
} |
| 3261 |
} |
| 3262 |
} |
| 3263 |
|
| 3264 |
|
| 3265 |
|
| 3266 |
|
| 3267 |
CBackendRepresentativeMemoryLabelCacheItem* combinedDetExistRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 3268 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNonDetExistRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 3269 |
|
| 3270 |
|
| 3271 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedDetExistRoleSetLabelData = getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDetExistRoleSetLabel, false); |
| 3272 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedNonDetExistRoleSetLabelData = getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDetExistRoleSetLabel, false); |
| 3273 |
|
| 3274 |
if (combinedDetExistRoleSetLabelData && combinedDetExistRoleSetLabelData->hasComplexCandiateInstancesItems() || combinedNonDetExistRoleSetLabelData && combinedNonDetExistRoleSetLabelData->hasComplexCandiateInstancesItems() || combinedNeigRoleSetLabelData && combinedNeigRoleSetLabelData->hasComplexCandiateInstancesItems()) { |
| 3275 |
QSet<COptimizedKPSetRoleInstancesItem*> complexRoleInstItemSet; |
| 3276 |
QSet<COptimizedKPSetRoleInstancesItem*> inverseComplexRoleInstItemSet; |
| 3277 |
if (combinedDetExistRoleSetLabelData) { |
| 3278 |
complexRoleInstItemSet += (*combinedDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(false)); |
| 3279 |
inverseComplexRoleInstItemSet += (*combinedDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(true)); |
| 3280 |
} |
| 3281 |
if (combinedNonDetExistRoleSetLabelData) { |
| 3282 |
complexRoleInstItemSet += (*combinedNonDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(false)); |
| 3283 |
inverseComplexRoleInstItemSet += (*combinedNonDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(true)); |
| 3284 |
} |
| 3285 |
if (combinedNeigRoleSetLabelData) { |
| 3286 |
complexRoleInstItemSet += (*combinedNeigRoleSetLabelData->getComplexCandiateInstancesItemSet(false)); |
| 3287 |
inverseComplexRoleInstItemSet += (*combinedNeigRoleSetLabelData->getComplexCandiateInstancesItemSet(true)); |
| 3288 |
} |
| 3289 |
|
| 3290 |
// verify that these role have corresponding fillers |
| 3291 |
function<bool(COptimizedKPSetRoleInstancesItem* complexRoleInstItem, bool handleInversed)> handleComplexRoleInstItemFunc = [&](COptimizedKPSetRoleInstancesItem* complexRoleInstItem, bool handleInversed)->bool { |
| 3292 |
|
| 3293 |
CRoleInstantiatedItem* visitRoleRedirectedItem = complexRoleInstItem; |
| 3294 |
CRoleInstantiatedItem* invRoleRedirectedItem = complexRoleInstItem->getInverseRoleRedirectedItem(); |
| 3295 |
if (handleInversed) { |
| 3296 |
if (invRoleRedirectedItem && complexRoleInstItem->getInverseRoleHierarchyNode()) { |
| 3297 |
visitRoleRedirectedItem = invRoleRedirectedItem; |
| 3298 |
} else { |
| 3299 |
return false; |
| 3300 |
} |
| 3301 |
} |
| 3302 |
|
| 3303 |
|
| 3304 |
if ((!excludeRoleSet || !excludeRoleSet->contains(complexRoleInstItem)) && !roleSetCollection.contains(visitRoleRedirectedItem)) { |
| 3305 |
|
| 3306 |
|
| 3307 |
QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* compDataHash = complexRoleInstItem->getIndividualIdComplexRoleDataHash(); |
| 3308 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = compDataHash->value(indiRealItemRef.getIndividualID()); |
| 3309 |
|
| 3310 |
|
| 3311 |
bool hasComplexInstance = false; |
| 3312 |
if (indiComplexData) { |
| 3313 |
|
| 3314 |
if (!collectKnown && indiComplexData->isInitialized(handleInversed)) { |
| 3315 |
hasComplexInstance = true; |
| 3316 |
|
| 3317 |
} |
| 3318 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3319 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(handleInversed, false); |
| 3320 |
if (possNeighbourInstanceHash) { |
| 3321 |
// TODO: make more efficient by adding/maintaining/using pointer to first known neighbour filler/instance |
| 3322 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd && !hasComplexInstance; ++itNeighInst) { |
| 3323 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 3324 |
cint64 destIndiId = itNeighInst.key(); |
| 3325 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 3326 |
if (collectKnown && instanceData && instanceData->mKnownInstance) { |
| 3327 |
hasComplexInstance = true; |
| 3328 |
} else if (!collectKnown && instanceData && !instanceData->mKnownInstance && instanceData->mPossibleInstance && !instanceData->mTestedInstance) { |
| 3329 |
hasComplexInstance = true; |
| 3330 |
} |
| 3331 |
} |
| 3332 |
} |
| 3333 |
|
| 3334 |
} else if (compDataHash->contains(indiRealItemRef.getIndividualID())) { |
| 3335 |
hasComplexInstance = true; |
| 3336 |
} |
| 3337 |
|
| 3338 |
if (hasComplexInstance) { |
| 3339 |
roleSetCollection.insert(visitRoleRedirectedItem); |
| 3340 |
} |
| 3341 |
|
| 3342 |
return true; |
| 3343 |
} |
| 3344 |
return false; |
| 3345 |
}; |
| 3346 |
|
| 3347 |
for (COptimizedKPSetRoleInstancesItem* complexRoleInstItem : complexRoleInstItemSet) { |
| 3348 |
bool handleInversed = target; |
| 3349 |
handleComplexRoleInstItemFunc(complexRoleInstItem, handleInversed); |
| 3350 |
} |
| 3351 |
for (COptimizedKPSetRoleInstancesItem* complexRoleInstItem : inverseComplexRoleInstItemSet) { |
| 3352 |
bool handleInversed = !target; |
| 3353 |
handleComplexRoleInstItemFunc(complexRoleInstItem, handleInversed); |
| 3354 |
} |
| 3355 |
} |
| 3356 |
} |
| 3357 |
|
| 3358 |
|
| 3359 |
return true; |
| 3360 |
} |
| 3361 |
|
| 3362 |
|
| 3363 |
|
| 3364 |
|
| 3365 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isSourceIndividualRole(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleInstantiatedItem* roleItem) { |
| 3366 |
COptimizedKPSetRoleInstancesRedirectionItem* roleRedirectionItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 3367 |
COptimizedKPSetRoleInstancesItem* roleInstItem = roleRedirectionItem->getRedirectedItem(); |
| 3368 |
bool roleItemInversed = roleRedirectionItem->isInversed(); |
| 3369 |
return isSourceIndividualRole(indiRealItemRef, roleInstItem, roleItemInversed); |
| 3370 |
} |
| 3371 |
|
| 3372 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresSourceIndividualRoleRealization(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleInstantiatedItem* roleItem) { |
| 3373 |
COptimizedKPSetRoleInstancesRedirectionItem* roleRedirectionItem = (COptimizedKPSetRoleInstancesRedirectionItem*)roleItem; |
| 3374 |
COptimizedKPSetRoleInstancesItem* roleInstItem = roleRedirectionItem->getRedirectedItem(); |
| 3375 |
bool roleItemInversed = roleRedirectionItem->isInversed(); |
| 3376 |
return requiresSourceIndividualRoleRealization(indiRealItemRef, roleInstItem, roleItemInversed); |
| 3377 |
} |
| 3378 |
|
| 3379 |
|
| 3380 |
|
| 3381 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isSourceIndividualRole(const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetRoleInstancesItem* roleItem, bool inversed) { |
| 3382 |
bool reqReal = false; |
| 3383 |
bool isRole = checkHasSourceTargetIndividualRole(indiRealItemRef, roleItem, inversed, reqReal); |
| 3384 |
return isRole; |
| 3385 |
} |
| 3386 |
|
| 3387 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresSourceIndividualRoleRealization(const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetRoleInstancesItem* roleItem, bool inversed) { |
| 3388 |
bool reqReal = false; |
| 3389 |
bool isRole = checkHasSourceTargetIndividualRole(indiRealItemRef, roleItem, inversed, reqReal); |
| 3390 |
if (isRole) { |
| 3391 |
return false; |
| 3392 |
} |
| 3393 |
if (reqReal) { |
| 3394 |
return true; |
| 3395 |
} |
| 3396 |
return false; |
| 3397 |
} |
| 3398 |
|
| 3399 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::checkHasSourceTargetIndividualRole(const CRealizationIndividualInstanceItemReference& indiRealItemRef, COptimizedKPSetRoleInstancesItem* roleItem, bool target, bool& requiresRealization) { |
| 3400 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 3401 |
if (individualItem) { |
| 3402 |
COptimizedKPSetRoleNeighbourInstancesHash* roleNeighInsHash = individualItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 3403 |
const COptimizedKPSetRoleNeighbourInstancesHashData& neighInstHashData = roleNeighInsHash->value(roleItem); |
| 3404 |
|
| 3405 |
COptimizedKPSetRoleInstancesHash* neighbourHash = nullptr; |
| 3406 |
COptimizedKPSetRoleInstancesHash* invNeighbourHash = nullptr; |
| 3407 |
if (!target) { |
| 3408 |
neighbourHash = neighInstHashData.mRoleSuccessorInstancesHash; |
| 3409 |
invNeighbourHash = neighInstHashData.mRolePredecessorInstancesHash; |
| 3410 |
} else { |
| 3411 |
neighbourHash = neighInstHashData.mRolePredecessorInstancesHash; |
| 3412 |
invNeighbourHash = neighInstHashData.mRoleSuccessorInstancesHash; |
| 3413 |
} |
| 3414 |
|
| 3415 |
|
| 3416 |
if (neighbourHash) { |
| 3417 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeigh = neighbourHash->constBegin(), itNeighEnd = neighbourHash->constEnd(); itNeigh != itNeighEnd; ++itNeigh) { |
| 3418 |
const COptimizedKPSetRoleInstancesHashData& roleInstHashData(itNeigh.value()); |
| 3419 |
COptimizedKPSetRoleInstancesData* roleInstData = roleInstHashData.mInstanceItemData; |
| 3420 |
if (roleInstData->mKnownInstance) { |
| 3421 |
return true; |
| 3422 |
} else if (!roleInstData->mKnownInstance && roleInstData->mPossibleInstance && !roleInstData->mTestedInstance) { |
| 3423 |
requiresRealization = true; |
| 3424 |
} |
| 3425 |
} |
| 3426 |
} |
| 3427 |
CRoleInstantiatedItem* invRoleRedirectedItem = roleItem->getInverseRoleRedirectedItem(); |
| 3428 |
if (invRoleRedirectedItem && invNeighbourHash && roleItem->getInverseRoleHierarchyNode()) { |
| 3429 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeigh = invNeighbourHash->constBegin(), itNeighEnd = invNeighbourHash->constEnd(); itNeigh != itNeighEnd; ++itNeigh) { |
| 3430 |
const COptimizedKPSetRoleInstancesHashData& roleInstHashData(itNeigh.value()); |
| 3431 |
COptimizedKPSetRoleInstancesData* roleInstData = roleInstHashData.mInstanceItemData; |
| 3432 |
if (roleInstData->mKnownInstance) { |
| 3433 |
return true; |
| 3434 |
} else if (!roleInstData->mKnownInstance && roleInstData->mPossibleInstance && !roleInstData->mTestedInstance) { |
| 3435 |
requiresRealization = true; |
| 3436 |
} |
| 3437 |
} |
| 3438 |
} |
| 3439 |
|
| 3440 |
} |
| 3441 |
|
| 3442 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(indiRealItemRef.getIndividualID()); |
| 3443 |
if (indiAssData) { |
| 3444 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 3445 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeigRoleSetLabelData = getRepresentativeCacheCombinedNeighbourRoleSetLabelItemData(combinedNeigRoleSetLabel, false); |
| 3446 |
if (combinedNeigRoleSetLabelData) { |
| 3447 |
QSet<COptimizedKPSetRoleInstancesItem*>* roleItemSet = combinedNeigRoleSetLabelData->getKnownInstancesItemSet(false); |
| 3448 |
QSet<COptimizedKPSetRoleInstancesItem*>* invRoleItemSet = combinedNeigRoleSetLabelData->getKnownInstancesItemSet(true); |
| 3449 |
|
| 3450 |
if (!target && roleItemSet->contains(roleItem) || target && invRoleItemSet->contains(roleItem)) { |
| 3451 |
return true; |
| 3452 |
} |
| 3453 |
} |
| 3454 |
|
| 3455 |
|
| 3456 |
|
| 3457 |
|
| 3458 |
CBackendRepresentativeMemoryLabelCacheItem* combinedDetExistRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 3459 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNonDetExistRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 3460 |
|
| 3461 |
|
| 3462 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedDetExistRoleSetLabelData = getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDetExistRoleSetLabel, false); |
| 3463 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedNonDetExistRoleSetLabelData = getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDetExistRoleSetLabel, false); |
| 3464 |
|
| 3465 |
if (combinedDetExistRoleSetLabelData && combinedDetExistRoleSetLabelData->hasComplexCandiateInstancesItems() || combinedNonDetExistRoleSetLabelData && combinedNonDetExistRoleSetLabelData->hasComplexCandiateInstancesItems() || combinedNeigRoleSetLabelData && combinedNeigRoleSetLabelData->hasComplexCandiateInstancesItems()) { |
| 3466 |
|
| 3467 |
bool requiresComplexRoleInstInvestigation = false; |
| 3468 |
|
| 3469 |
QSet<COptimizedKPSetRoleInstancesItem*> complexRoleInstItemSet; |
| 3470 |
QSet<COptimizedKPSetRoleInstancesItem*> inverseComplexRoleInstItemSet; |
| 3471 |
if (combinedDetExistRoleSetLabelData && combinedDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(target)->contains(roleItem)) { |
| 3472 |
requiresComplexRoleInstInvestigation = true; |
| 3473 |
} |
| 3474 |
if (combinedNonDetExistRoleSetLabelData && combinedNonDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(target)->contains(roleItem)) { |
| 3475 |
requiresComplexRoleInstInvestigation = true; |
| 3476 |
} |
| 3477 |
if (combinedNeigRoleSetLabelData && combinedNeigRoleSetLabelData->getComplexCandiateInstancesItemSet(target)->contains(roleItem)) { |
| 3478 |
requiresComplexRoleInstInvestigation = true; |
| 3479 |
} |
| 3480 |
|
| 3481 |
// verify that these role have corresponding fillers |
| 3482 |
if (requiresComplexRoleInstInvestigation) { |
| 3483 |
|
| 3484 |
|
| 3485 |
|
| 3486 |
QHash<cint64, COptimizedKPSetIndividualComplexRoleData*>* compDataHash = roleItem->getIndividualIdComplexRoleDataHash(); |
| 3487 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = compDataHash->value(indiRealItemRef.getIndividualID()); |
| 3488 |
|
| 3489 |
if (indiComplexData) { |
| 3490 |
|
| 3491 |
if (indiComplexData->isInitialized(!target)) { |
| 3492 |
requiresRealization = true; |
| 3493 |
} |
| 3494 |
|
| 3495 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3496 |
COptimizedKPSetRoleInstancesHash* possNeighbourInstanceHash = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstancesHash(!target, false); |
| 3497 |
if (possNeighbourInstanceHash) { |
| 3498 |
// TODO: make more efficient by adding/maintaining/using pointer to first known neighbour filler/instance |
| 3499 |
for (COptimizedKPSetRoleInstancesHash::const_iterator itNeighInst = possNeighbourInstanceHash->constBegin(), itNeighInstEnd = possNeighbourInstanceHash->constEnd(); itNeighInst != itNeighInstEnd; ++itNeighInst) { |
| 3500 |
const COptimizedKPSetRoleInstancesHashData& destIndiInstanceDat = itNeighInst.value(); |
| 3501 |
cint64 destIndiId = itNeighInst.key(); |
| 3502 |
COptimizedKPSetRoleInstancesData* instanceData = destIndiInstanceDat.mInstanceItemData; |
| 3503 |
if (instanceData && instanceData->mKnownInstance) { |
| 3504 |
return true; |
| 3505 |
} else if (instanceData && !instanceData->mKnownInstance && instanceData->mPossibleInstance && !instanceData->mTestedInstance) { |
| 3506 |
requiresRealization = true; |
| 3507 |
} |
| 3508 |
} |
| 3509 |
} |
| 3510 |
} else if (!compDataHash->contains(indiRealItemRef.getIndividualID())) { |
| 3511 |
requiresRealization = true; |
| 3512 |
} |
| 3513 |
|
| 3514 |
return false; |
| 3515 |
}; |
| 3516 |
|
| 3517 |
} |
| 3518 |
} |
| 3519 |
|
| 3520 |
|
| 3521 |
return false; |
| 3522 |
} |
| 3523 |
|
| 3524 |
|
| 3525 |
|
| 3526 |
|
| 3527 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresSourceIndividualRolesRealization(const CRealizationIndividualInstanceItemReference& sourceIndiRealItemRef, bool onlyOnePerRole) { |
| 3528 |
QSet<CRoleInstantiatedItem*> knownRoleItemSet; |
| 3529 |
if (onlyOnePerRole) { |
| 3530 |
collectSourceTargetIndividualRoles(sourceIndiRealItemRef, false, true, knownRoleItemSet); |
| 3531 |
} |
| 3532 |
QSet<CRoleInstantiatedItem*> visitRoleItemSet; |
| 3533 |
collectSourceTargetIndividualRoles(sourceIndiRealItemRef, false, false, visitRoleItemSet, &knownRoleItemSet); |
| 3534 |
return !visitRoleItemSet.isEmpty(); |
| 3535 |
} |
| 3536 |
|
| 3537 |
|
| 3538 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresSourceIndividualRolesRealization(const CRealizationIndividualInstanceItemReference& sourceIndiRealItemRef, CRoleInstantiatedItem* roleItem, bool onlyOne) { |
| 3539 |
QSet<CRoleInstantiatedItem*> knownRoleItemSet; |
| 3540 |
if (onlyOne) { |
| 3541 |
collectSourceTargetIndividualRoles(sourceIndiRealItemRef, false, true, knownRoleItemSet); |
| 3542 |
} |
| 3543 |
if (knownRoleItemSet.contains(roleItem)) { |
| 3544 |
return true; |
| 3545 |
} |
| 3546 |
QSet<CRoleInstantiatedItem*> visitRoleItemSet; |
| 3547 |
collectSourceTargetIndividualRoles(sourceIndiRealItemRef, false, false, visitRoleItemSet, &knownRoleItemSet); |
| 3548 |
return visitRoleItemSet.contains(roleItem); |
| 3549 |
} |
| 3550 |
|
| 3551 |
|
| 3552 |
|
| 3553 |
|
| 3554 |
|
| 3555 |
|
| 3556 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitBetweeenIndividualRoles(const CRealizationIndividualInstanceItemReference& sourceIndiRealItemRef, const CRealizationIndividualInstanceItemReference& targetIndiRealItemRef, CRoleRealizationInstantiatedVisitor* visitor) { |
| 3557 |
QSet<CRoleInstantiatedItem*> visitRoleItemSet; |
| 3558 |
COptimizedKPSetIndividualItem* sourceIndiRealItem = (COptimizedKPSetIndividualItem*)sourceIndiRealItemRef.getRealizationInstanceItem(); |
| 3559 |
bool continueVisiting = true; |
| 3560 |
if (sourceIndiRealItem) { |
| 3561 |
COptimizedKPSetRoleNeighbourInstancesHash* roleNeighInsHash = sourceIndiRealItem->getKnownPossibleRoleNeighboursInstancesHash(); |
| 3562 |
for (COptimizedKPSetRoleNeighbourInstancesHash::const_iterator it = roleNeighInsHash->constBegin(), itEnd = roleNeighInsHash->constEnd(); it != itEnd; ++it) { |
| 3563 |
COptimizedKPSetRoleInstancesItem* roleItem(it.key()); |
| 3564 |
const COptimizedKPSetRoleNeighbourInstancesHashData& neighInstHashData(it.value()); |
| 3565 |
|
| 3566 |
COptimizedKPSetRoleInstancesHash* neighbourHash = nullptr; |
| 3567 |
COptimizedKPSetRoleInstancesHash* invNeighbourHash = nullptr; |
| 3568 |
neighbourHash = neighInstHashData.mRoleSuccessorInstancesHash; |
| 3569 |
invNeighbourHash = neighInstHashData.mRolePredecessorInstancesHash; |
| 3570 |
|
| 3571 |
if (neighbourHash) { |
| 3572 |
COptimizedKPSetRoleInstancesHashData hashData = neighbourHash->value(targetIndiRealItemRef.getIndividualID()); |
| 3573 |
if (hashData.mInstanceItemData && hashData.mInstanceItemData->mKnownInstance) { |
| 3574 |
visitRoleItemSet.insert(roleItem); |
| 3575 |
} |
| 3576 |
} |
| 3577 |
CRoleInstantiatedItem* invRoleRedirectedItem = roleItem->getInverseRoleRedirectedItem(); |
| 3578 |
if (invRoleRedirectedItem && roleItem->getInverseRoleHierarchyNode() && invNeighbourHash) { |
| 3579 |
COptimizedKPSetRoleInstancesHashData hashData = invNeighbourHash->value(targetIndiRealItemRef.getIndividualID()); |
| 3580 |
if (hashData.mInstanceItemData && hashData.mInstanceItemData->mKnownInstance) { |
| 3581 |
visitRoleItemSet.insert(invRoleRedirectedItem); |
| 3582 |
} |
| 3583 |
} |
| 3584 |
} |
| 3585 |
} |
| 3586 |
|
| 3587 |
CBackendRepresentativeMemoryCacheIndividualAssociationData* indiAssData = mBackendAssocCacheReader->getIndividualAssociationData(sourceIndiRealItemRef.getIndividualID()); |
| 3588 |
if (indiAssData) { |
| 3589 |
CBackendRepresentativeMemoryCacheIndividualNeighbourRoleSetHash* neighbourRoleSetLabelHash = indiAssData->getNeighbourRoleSetHash(); |
| 3590 |
if (neighbourRoleSetLabelHash) { |
| 3591 |
CBackendRepresentativeMemoryLabelCacheItem* singleNeigRoleSetLabel = neighbourRoleSetLabelHash->getNeighbourRoleSetLabel(targetIndiRealItemRef.getIndividualID()); |
| 3592 |
if (singleNeigRoleSetLabel) { |
| 3593 |
|
| 3594 |
COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData* singleNeigRoleSetLabelData = getRepresentativeCacheSingleNeighbourRoleSetLabelItemData(singleNeigRoleSetLabel, false); |
| 3595 |
if (singleNeigRoleSetLabelData) { |
| 3596 |
for (COptimizedKPSetRoleInstancesItem* roleItem : *singleNeigRoleSetLabelData->getKnownInstancesItemList(false)) { |
| 3597 |
visitRoleItemSet.insert(roleItem); |
| 3598 |
} |
| 3599 |
for (COptimizedKPSetRoleInstancesItem* invRoleItem : *singleNeigRoleSetLabelData->getKnownInstancesItemList(true)) { |
| 3600 |
CRoleInstantiatedItem* invRoleRedirectedItem = invRoleItem->getInverseRoleRedirectedItem(); |
| 3601 |
if (invRoleRedirectedItem && invRoleItem->getInverseRoleHierarchyNode()) { |
| 3602 |
visitRoleItemSet.insert(invRoleRedirectedItem); |
| 3603 |
} |
| 3604 |
} |
| 3605 |
} |
| 3606 |
} |
| 3607 |
} |
| 3608 |
|
| 3609 |
|
| 3610 |
|
| 3611 |
CBackendRepresentativeMemoryLabelCacheItem* combinedDetExistRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 3612 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNonDetExistRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NONDETERMINISTIC_COMBINED_EXISTENTIAL_INSTANTIATED_ROLE_SET_LABEL); |
| 3613 |
CBackendRepresentativeMemoryLabelCacheItem* combinedNeigRoleSetLabel = indiAssData->getLabelCacheEntry(CBackendRepresentativeMemoryLabelCacheItem::NEIGHBOUR_INSTANTIATED_ROLE_SET_COMBINATION_LABEL); |
| 3614 |
|
| 3615 |
|
| 3616 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedDetExistRoleSetLabelData = getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDetExistRoleSetLabel, false); |
| 3617 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* combinedNonDetExistRoleSetLabelData = getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(combinedDetExistRoleSetLabel, false); |
| 3618 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* combinedNeigRoleSetLabelData = getRepresentativeCacheCombinedNeighbourRoleSetLabelItemData(combinedNeigRoleSetLabel, false); |
| 3619 |
|
| 3620 |
if (combinedDetExistRoleSetLabelData && combinedDetExistRoleSetLabelData->hasComplexCandiateInstancesItems() || combinedNonDetExistRoleSetLabelData && combinedNonDetExistRoleSetLabelData->hasComplexCandiateInstancesItems() || combinedNeigRoleSetLabelData && combinedNeigRoleSetLabelData->hasComplexCandiateInstancesItems()) { |
| 3621 |
QSet<COptimizedKPSetRoleInstancesItem*> complexRoleInstItemSet; |
| 3622 |
QSet<COptimizedKPSetRoleInstancesItem*> inverseComplexRoleInstItemSet; |
| 3623 |
if (combinedDetExistRoleSetLabelData) { |
| 3624 |
complexRoleInstItemSet += (*combinedDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(false)); |
| 3625 |
inverseComplexRoleInstItemSet += (*combinedDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(true)); |
| 3626 |
} |
| 3627 |
if (combinedNonDetExistRoleSetLabelData) { |
| 3628 |
complexRoleInstItemSet += (*combinedNonDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(false)); |
| 3629 |
inverseComplexRoleInstItemSet += (*combinedNonDetExistRoleSetLabelData->getComplexCandiateInstancesItemSet(true)); |
| 3630 |
} |
| 3631 |
if (combinedNeigRoleSetLabelData) { |
| 3632 |
complexRoleInstItemSet += (*combinedNeigRoleSetLabelData->getComplexCandiateInstancesItemSet(false)); |
| 3633 |
inverseComplexRoleInstItemSet += (*combinedNeigRoleSetLabelData->getComplexCandiateInstancesItemSet(true)); |
| 3634 |
} |
| 3635 |
|
| 3636 |
|
| 3637 |
// verify that these role have corresponding instances |
| 3638 |
function<bool(COptimizedKPSetRoleInstancesItem* complexRoleInstItem, bool handleInversed)> handleComplexRoleInstItemFunc = [&](COptimizedKPSetRoleInstancesItem* complexRoleInstItem, bool handleInversed)->bool { |
| 3639 |
|
| 3640 |
CRoleInstantiatedItem* visitRoleRedirectedItem = complexRoleInstItem; |
| 3641 |
CRoleInstantiatedItem* invRoleRedirectedItem = complexRoleInstItem->getInverseRoleRedirectedItem(); |
| 3642 |
if (handleInversed) { |
| 3643 |
if (invRoleRedirectedItem && complexRoleInstItem->getInverseRoleHierarchyNode()) { |
| 3644 |
visitRoleRedirectedItem = invRoleRedirectedItem; |
| 3645 |
} else { |
| 3646 |
return false; |
| 3647 |
} |
| 3648 |
} |
| 3649 |
|
| 3650 |
if (!visitRoleItemSet.contains(visitRoleRedirectedItem)) { |
| 3651 |
COptimizedKPSetIndividualComplexRoleData* indiComplexData = complexRoleInstItem->getIndividualIdComplexRoleData(sourceIndiRealItemRef.getIndividualID(), false); |
| 3652 |
|
| 3653 |
if (indiComplexData) { |
| 3654 |
|
| 3655 |
COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData* indiExplicitIndirectLinkComplexRepresentationData = (COptimizedKPSetIndividualComplexRoleExplicitIndirectLinksData*)indiComplexData; |
| 3656 |
COptimizedKPSetRoleInstancesData* instanceData = indiExplicitIndirectLinkComplexRepresentationData->getRoleNeighbourInstanceItemData(handleInversed, targetIndiRealItemRef.getIndividualID(), false); |
| 3657 |
|
| 3658 |
if (instanceData && instanceData->mKnownInstance) { |
| 3659 |
visitRoleItemSet.insert(visitRoleRedirectedItem); |
| 3660 |
} |
| 3661 |
} |
| 3662 |
|
| 3663 |
return true; |
| 3664 |
} |
| 3665 |
return false; |
| 3666 |
}; |
| 3667 |
|
| 3668 |
for (COptimizedKPSetRoleInstancesItem* complexRoleInstItem : complexRoleInstItemSet) { |
| 3669 |
handleComplexRoleInstItemFunc(complexRoleInstItem, false); |
| 3670 |
} |
| 3671 |
for (COptimizedKPSetRoleInstancesItem* complexRoleInstItem : inverseComplexRoleInstItemSet) { |
| 3672 |
handleComplexRoleInstItemFunc(complexRoleInstItem, true); |
| 3673 |
} |
| 3674 |
} |
| 3675 |
} |
| 3676 |
|
| 3677 |
for (QSet<CRoleInstantiatedItem*>::const_iterator it = visitRoleItemSet.constBegin(), itEnd = visitRoleItemSet.constEnd(); it != itEnd && continueVisiting; ++it) { |
| 3678 |
CRoleInstantiatedItem* roleInstItem(*it); |
| 3679 |
continueVisiting = visitor->visitRoleInstantiated(roleInstItem, this); |
| 3680 |
} |
| 3681 |
return true; |
| 3682 |
} |
| 3683 |
|
| 3684 |
|
| 3685 |
|
| 3686 |
|
| 3687 |
|
| 3688 |
|
| 3689 |
|
| 3690 |
|
| 3691 |
|
| 3692 |
|
| 3693 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::visitIndividuals(const CRealizationIndividualInstanceItemReference& indiRealItemRef, CRoleRealizationIndividualVisitor* visitor) { |
| 3694 |
COptimizedKPSetIndividualItem* individualItem = (COptimizedKPSetIndividualItem*)indiRealItemRef.getRealizationInstanceItem(); |
| 3695 |
bool continueVisiting = true; |
| 3696 |
if (individualItem) { |
| 3697 |
QSet<CIndividualReference>* individualSet = individualItem->getKnownSameIndividualSet(); |
| 3698 |
for (QSet<CIndividualReference>::const_iterator it = individualSet->constBegin(), itEnd = individualSet->constEnd(); it != itEnd && continueVisiting; ++it) { |
| 3699 |
CIndividualReference indiRef(*it); |
| 3700 |
continueVisiting = visitor->visitIndividual(indiRef, this); |
| 3701 |
} |
| 3702 |
} else { |
| 3703 |
CBackendRepresentativeMemoryLabelCacheItem* sameIndilabelItem = mBackendAssocCacheReader->getIndividualAssociatedCacheLabelItem(indiRealItemRef.getIndividualID(), CBackendRepresentativeMemoryLabelCacheItem::DETERMINISTIC_SAME_INDIVIDUAL_SET_LABEL); |
| 3704 |
if (sameIndilabelItem) { |
| 3705 |
mBackendAssocCacheReader->visitIndividualIdsOfAssociatedIndividualSetLabel(nullptr, sameIndilabelItem, [&](cint64 indiId)->bool { |
| 3706 |
continueVisiting = visitor->visitIndividual(indiId, this); |
| 3707 |
return continueVisiting; |
| 3708 |
}); |
| 3709 |
} else { |
| 3710 |
continueVisiting = visitor->visitIndividual(indiRealItemRef, this); |
| 3711 |
} |
| 3712 |
} |
| 3713 |
return true; |
| 3714 |
} |
| 3715 |
|
| 3716 |
|
| 3717 |
|
| 3718 |
|
| 3719 |
|
| 3720 |
|
| 3721 |
|
| 3722 |
|
| 3723 |
|
| 3724 |
|
| 3725 |
|
| 3726 |
|
| 3727 |
|
| 3728 |
COptimizedKPSetConceptInstancesItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getTopInstancesItem() { |
| 3729 |
return mTopConceptInstancesItem; |
| 3730 |
} |
| 3731 |
|
| 3732 |
COptimizedKPSetConceptInstancesItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getBottomInstancesItem() { |
| 3733 |
return mBottomConceptInstancesItem; |
| 3734 |
} |
| 3735 |
|
| 3736 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestingPossibleSameIndividualCount() { |
| 3737 |
return mTestingPossibleSameIndividualCount; |
| 3738 |
} |
| 3739 |
|
| 3740 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestingPossibleConceptInstanceCount() { |
| 3741 |
return mTestingPossibleConceptInstanceCount; |
| 3742 |
} |
| 3743 |
|
| 3744 |
|
| 3745 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setTestingPossibleSameIndividualCount(cint64 testCount) { |
| 3746 |
mTestingPossibleSameIndividualCount = testCount; |
| 3747 |
return this; |
| 3748 |
} |
| 3749 |
|
| 3750 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setTestingPossibleConceptInstanceCount(cint64 testCount) { |
| 3751 |
mTestingPossibleConceptInstanceCount = testCount; |
| 3752 |
return this; |
| 3753 |
} |
| 3754 |
|
| 3755 |
|
| 3756 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestingPossibleSameIndividualCount(cint64 incCount) { |
| 3757 |
mTestingPossibleSameIndividualCount += incCount; |
| 3758 |
return this; |
| 3759 |
} |
| 3760 |
|
| 3761 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestingPossibleSameIndividualCount(cint64 decCount) { |
| 3762 |
mTestingPossibleSameIndividualCount -= decCount; |
| 3763 |
return this; |
| 3764 |
} |
| 3765 |
|
| 3766 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestingPossibleConceptInstanceCount(cint64 incCount) { |
| 3767 |
mTestingPossibleConceptInstanceCount += incCount; |
| 3768 |
return this; |
| 3769 |
} |
| 3770 |
|
| 3771 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestingPossibleConceptInstanceCount(cint64 decCount) { |
| 3772 |
mTestingPossibleConceptInstanceCount -= decCount; |
| 3773 |
return this; |
| 3774 |
} |
| 3775 |
|
| 3776 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasTestingPossibleSameIndividual() { |
| 3777 |
return mTestingPossibleSameIndividualCount > 0; |
| 3778 |
} |
| 3779 |
|
| 3780 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasTestingPossibleConceptInstances() { |
| 3781 |
return mTestingPossibleConceptInstanceCount > 0; |
| 3782 |
} |
| 3783 |
|
| 3784 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestingPossibleRoleInstanceCount() { |
| 3785 |
return mTestingPossibleRoleInstanceCount; |
| 3786 |
} |
| 3787 |
|
| 3788 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setTestingPossibleRoleInstanceCount(cint64 testCount) { |
| 3789 |
mTestingPossibleRoleInstanceCount = testCount; |
| 3790 |
return this; |
| 3791 |
} |
| 3792 |
|
| 3793 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasTestingPossibleRoleInstances() { |
| 3794 |
return mTestingPossibleRoleInstanceCount > 0; |
| 3795 |
} |
| 3796 |
|
| 3797 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestingPossibleRoleInstanceCount(cint64 incCount) { |
| 3798 |
mTestingPossibleRoleInstanceCount += incCount; |
| 3799 |
return this; |
| 3800 |
} |
| 3801 |
|
| 3802 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestingPossibleRoleInstanceCount(cint64 decCount) { |
| 3803 |
mTestingPossibleRoleInstanceCount -= decCount; |
| 3804 |
return this; |
| 3805 |
} |
| 3806 |
|
| 3807 |
|
| 3808 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestedPossibleRoleInstancesCount() { |
| 3809 |
return mTestedPossibleRoleInstancesCount; |
| 3810 |
} |
| 3811 |
|
| 3812 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getOpenPossibleRoleInstancesCount() { |
| 3813 |
return mOpenPossibleRoleInstancesCount; |
| 3814 |
} |
| 3815 |
|
| 3816 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getInitializedRoleInstancesCount() { |
| 3817 |
return mInitializedRoleInstancesCount; |
| 3818 |
} |
| 3819 |
|
| 3820 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getRemaningInitalizingRoleInstancesCount() { |
| 3821 |
return mRemainingInitalizingRoleInstancesCount; |
| 3822 |
} |
| 3823 |
|
| 3824 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestedPossibleRoleInstancesCount(cint64 incCount) { |
| 3825 |
mTestedPossibleRoleInstancesCount += incCount; |
| 3826 |
return this; |
| 3827 |
} |
| 3828 |
|
| 3829 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incOpenPossibleRoleInstancesCount(cint64 incCount) { |
| 3830 |
mOpenPossibleRoleInstancesCount += incCount; |
| 3831 |
return this; |
| 3832 |
} |
| 3833 |
|
| 3834 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestedPossibleRoleInstancesCount(cint64 decCount) { |
| 3835 |
mTestedPossibleRoleInstancesCount -= decCount; |
| 3836 |
return this; |
| 3837 |
} |
| 3838 |
|
| 3839 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decOpenPossibleRoleInstancesCount(cint64 decCount) { |
| 3840 |
mOpenPossibleRoleInstancesCount -= decCount; |
| 3841 |
return this; |
| 3842 |
} |
| 3843 |
|
| 3844 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incInitializedRoleInstancesCount(cint64 incCount) { |
| 3845 |
mInitializedRoleInstancesCount += incCount; |
| 3846 |
return this; |
| 3847 |
} |
| 3848 |
|
| 3849 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decInitializedRoleInstancesCount(cint64 decCount) { |
| 3850 |
mInitializedRoleInstancesCount -= decCount; |
| 3851 |
return this; |
| 3852 |
} |
| 3853 |
|
| 3854 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incRemaningInitalizingInstancesCount(cint64 incCount) { |
| 3855 |
mRemainingInitalizingRoleInstancesCount += incCount; |
| 3856 |
return this; |
| 3857 |
} |
| 3858 |
|
| 3859 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decRemaningInitalizingInstancesCount(cint64 decCount) { |
| 3860 |
mRemainingInitalizingRoleInstancesCount -= decCount; |
| 3861 |
return this; |
| 3862 |
} |
| 3863 |
|
| 3864 |
|
| 3865 |
COptimizedKPSetRoleInstancesItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getTopRoleInstancesItem() { |
| 3866 |
return mTopRoleInstancesItem; |
| 3867 |
} |
| 3868 |
|
| 3869 |
COptimizedKPSetRoleInstancesItem* COptimizedRepresentativeKPSetOntologyRealizingItem::getBottomRoleInstancesItem() { |
| 3870 |
return mBottomRoleInstancesItem; |
| 3871 |
} |
| 3872 |
|
| 3873 |
|
| 3874 |
QHash<CConcept*,COptimizedKPSetRoleInstancesItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getMarkerConceptInstancesItemHash() { |
| 3875 |
return &mMarkerConceptInstancesItemHash; |
| 3876 |
} |
| 3877 |
|
| 3878 |
|
| 3879 |
|
| 3880 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addRoleCandidateInitalizingIndividualsItem(COptimizedKPSetIndividualItem* indiItem) { |
| 3881 |
mRoleCandidateInitalizingIndividualsItemList.append(indiItem); |
| 3882 |
return this; |
| 3883 |
} |
| 3884 |
|
| 3885 |
QList<COptimizedKPSetIndividualItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRoleCandidateInitalizingIndividualsItemList() { |
| 3886 |
return &mRoleCandidateInitalizingIndividualsItemList; |
| 3887 |
} |
| 3888 |
|
| 3889 |
|
| 3890 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isConceptRealizationInstalled() { |
| 3891 |
return mConceptRealizationInstalled; |
| 3892 |
} |
| 3893 |
|
| 3894 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setConceptRealizationInstalled(bool installed) { |
| 3895 |
mConceptRealizationInstalled = installed;; |
| 3896 |
return this; |
| 3897 |
} |
| 3898 |
|
| 3899 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isRoleRealizationInstalled() { |
| 3900 |
return mRoleRealizationInstalled; |
| 3901 |
} |
| 3902 |
|
| 3903 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setRoleRealizationInstalled(bool installed) { |
| 3904 |
mRoleRealizationInstalled = installed; |
| 3905 |
return this; |
| 3906 |
} |
| 3907 |
|
| 3908 |
|
| 3909 |
|
| 3910 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isSameRealizationInstalled() { |
| 3911 |
return mSameRealizationInstalled; |
| 3912 |
} |
| 3913 |
|
| 3914 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setSameRealizationInstalled(bool installed) { |
| 3915 |
mSameRealizationInstalled = installed;; |
| 3916 |
return this; |
| 3917 |
} |
| 3918 |
|
| 3919 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getPropagatingRoleInstanceCandidatesCount() { |
| 3920 |
return mPropagatingRoleInstanceCandidateCount; |
| 3921 |
} |
| 3922 |
|
| 3923 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setPropagatingRoleInstanceCandidatesCount(cint64 testCount) { |
| 3924 |
mPropagatingRoleInstanceCandidateCount = testCount; |
| 3925 |
return this; |
| 3926 |
} |
| 3927 |
|
| 3928 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasPropagatingRoleInstanceCandidates() { |
| 3929 |
return mPropagatingRoleInstanceCandidateCount > 0; |
| 3930 |
} |
| 3931 |
|
| 3932 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incPropagatingRoleInstanceCandidatesCount(cint64 incCount) { |
| 3933 |
mPropagatingRoleInstanceCandidateCount += incCount; |
| 3934 |
return this; |
| 3935 |
} |
| 3936 |
|
| 3937 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decPropagatingRoleInstanceCandidatesCount(cint64 decCount) { |
| 3938 |
mPropagatingRoleInstanceCandidateCount -= decCount; |
| 3939 |
return this; |
| 3940 |
} |
| 3941 |
|
| 3942 |
|
| 3943 |
|
| 3944 |
|
| 3945 |
|
| 3946 |
|
| 3947 |
|
| 3948 |
|
| 3949 |
cint64 COptimizedRepresentativeKPSetOntologyRealizingItem::getTestingRoleInstanceCandidatesCount() { |
| 3950 |
return mTestingRoleInstanceCandidateCount; |
| 3951 |
} |
| 3952 |
|
| 3953 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setTestingRoleInstanceCandidatesCount(cint64 testCount) { |
| 3954 |
mTestingRoleInstanceCandidateCount = testCount; |
| 3955 |
return this; |
| 3956 |
} |
| 3957 |
|
| 3958 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasTestingRoleInstanceCandidates() { |
| 3959 |
return mTestingRoleInstanceCandidateCount > 0; |
| 3960 |
} |
| 3961 |
|
| 3962 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::incTestingRoleInstanceCandidatesCount(cint64 incCount) { |
| 3963 |
mTestingRoleInstanceCandidateCount += incCount; |
| 3964 |
return this; |
| 3965 |
} |
| 3966 |
|
| 3967 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::decTestingRoleInstanceCandidatesCount(cint64 decCount) { |
| 3968 |
mTestingRoleInstanceCandidateCount -= decCount; |
| 3969 |
return this; |
| 3970 |
} |
| 3971 |
|
| 3972 |
|
| 3973 |
|
| 3974 |
|
| 3975 |
|
| 3976 |
|
| 3977 |
|
| 3978 |
|
| 3979 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isCountingPossibleConceptInstancesTesting() { |
| 3980 |
return mCountingPossibleConceptInstancesTesting; |
| 3981 |
} |
| 3982 |
|
| 3983 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isCountingPossibleRoleInstancesTesting() { |
| 3984 |
return mCountingPossibleRoleInstancesTesting; |
| 3985 |
} |
| 3986 |
|
| 3987 |
|
| 3988 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isCountingPossibleSameInstancesTesting() { |
| 3989 |
return mCountingPossibleSameInstancesTesting; |
| 3990 |
} |
| 3991 |
|
| 3992 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setCountingPossibleConceptInstancesTesting(bool counting) { |
| 3993 |
mCountingPossibleConceptInstancesTesting = counting; |
| 3994 |
return this; |
| 3995 |
} |
| 3996 |
|
| 3997 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setCountingPossibleRoleInstancesTesting(bool counting) { |
| 3998 |
mCountingPossibleRoleInstancesTesting = counting; |
| 3999 |
return this; |
| 4000 |
} |
| 4001 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setCountingPossibleSameInstancesTesting(bool counting) { |
| 4002 |
mCountingPossibleSameInstancesTesting = counting; |
| 4003 |
return this; |
| 4004 |
} |
| 4005 |
|
| 4006 |
|
| 4007 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setTemporarySameRealizationOntology(CConcreteOntology* tmpOntology) { |
| 4008 |
mTempSameRealizationOntology = tmpOntology; |
| 4009 |
return this; |
| 4010 |
} |
| 4011 |
|
| 4012 |
CConcreteOntology* COptimizedRepresentativeKPSetOntologyRealizingItem::getTemporarySameRealizationOntology() { |
| 4013 |
return mTempSameRealizationOntology; |
| 4014 |
} |
| 4015 |
|
| 4016 |
|
| 4017 |
QList<COptimizedKPSetIndividualItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getPossibleSameIndividualsItemList() { |
| 4018 |
return &mPossibleSameIndiItemList; |
| 4019 |
} |
| 4020 |
|
| 4021 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addPossibleSameIndividualsItem(COptimizedKPSetIndividualItem* indiItem) { |
| 4022 |
mPossibleSameIndiItemList.append(indiItem); |
| 4023 |
return this; |
| 4024 |
} |
| 4025 |
|
| 4026 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::requiresIndividualDependenceTracking() { |
| 4027 |
return mIndiDepTrackReq; |
| 4028 |
} |
| 4029 |
|
| 4030 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setIndividualDependenceTrackingRequired(bool indiDepTrackingRequired) { |
| 4031 |
mIndiDepTrackReq = indiDepTrackingRequired; |
| 4032 |
return this; |
| 4033 |
} |
| 4034 |
|
| 4035 |
|
| 4036 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isExtraConsistencyTestingStepRequired() { |
| 4037 |
return mExtraConsistencyTestingRequired; |
| 4038 |
} |
| 4039 |
|
| 4040 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setExtraConsistencyTestingStepRequired(bool required) { |
| 4041 |
mExtraConsistencyTestingRequired = required; |
| 4042 |
return this; |
| 4043 |
} |
| 4044 |
|
| 4045 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isExtraConsistencyTesting() { |
| 4046 |
return mExtraConsistencyTesting; |
| 4047 |
} |
| 4048 |
|
| 4049 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setExtraConsistencyTesting(bool testing) { |
| 4050 |
mExtraConsistencyTesting = testing; |
| 4051 |
return this; |
| 4052 |
} |
| 4053 |
|
| 4054 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isExtraConsistencyTested() { |
| 4055 |
return mExtraConsistencyTested; |
| 4056 |
} |
| 4057 |
|
| 4058 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setExtraConsistencyTested(bool tested) { |
| 4059 |
mExtraConsistencyTested = tested; |
| 4060 |
return this; |
| 4061 |
} |
| 4062 |
|
| 4063 |
|
| 4064 |
QList<COptimizedKPSetIndividualItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getInstantiatedItemList() { |
| 4065 |
return &mInstantiatedItemContainer; |
| 4066 |
} |
| 4067 |
|
| 4068 |
QTime* COptimizedRepresentativeKPSetOntologyRealizingItem::getInitializationTime() { |
| 4069 |
return &mInitTime; |
| 4070 |
} |
| 4071 |
|
| 4072 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isAllSameIndividualsProcessing() { |
| 4073 |
return mAllSameIndividualsProcessing; |
| 4074 |
} |
| 4075 |
|
| 4076 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setAllSameIndividualsProcessing(bool processing) { |
| 4077 |
mAllSameIndividualsProcessing = processing; |
| 4078 |
return this; |
| 4079 |
} |
| 4080 |
|
| 4081 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isAllConceptInstancesProcessing() { |
| 4082 |
return mAllConceptInstancesProcessing; |
| 4083 |
} |
| 4084 |
|
| 4085 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setAllConceptInstancesProcessing(bool processing) { |
| 4086 |
mAllConceptInstancesProcessing = processing; |
| 4087 |
return this; |
| 4088 |
} |
| 4089 |
|
| 4090 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::isAllRoleInstancesProcessing() { |
| 4091 |
return mAllRoleInstancesProcessing; |
| 4092 |
} |
| 4093 |
|
| 4094 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::setAllRoleInstancesProcessing(bool processing) { |
| 4095 |
mAllRoleInstancesProcessing = processing; |
| 4096 |
return this; |
| 4097 |
} |
| 4098 |
|
| 4099 |
|
| 4100 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addEntailmentIndividualConceptInstanceTestingItem(CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem* queueItem) { |
| 4101 |
mEntIndConInstTestList.append(queueItem); |
| 4102 |
return this; |
| 4103 |
} |
| 4104 |
|
| 4105 |
QList<CRealizationEntailmentQueuedIndividualConceptInstanceTestingItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getEntailmentIndividualConceptInstanceTestingItemList() { |
| 4106 |
return &mEntIndConInstTestList; |
| 4107 |
} |
| 4108 |
|
| 4109 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasEntailmentIndividualConceptInstanceTestingItems() { |
| 4110 |
return !mEntIndConInstTestList.isEmpty(); |
| 4111 |
} |
| 4112 |
|
| 4113 |
|
| 4114 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addEntailmentIndividualsRoleInstanceTestingItem(CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem* queueItem) { |
| 4115 |
mEntIndsRoleInstTestList.append(queueItem); |
| 4116 |
return this; |
| 4117 |
} |
| 4118 |
|
| 4119 |
QList<CRealizationEntailmentQueuedIndividualsRoleInstanceTestingItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getEntailmentIndividualsRoleInstanceTestingItemList() { |
| 4120 |
return &mEntIndsRoleInstTestList; |
| 4121 |
} |
| 4122 |
|
| 4123 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasEntailmentIndividualsRoleInstanceTestingItems() { |
| 4124 |
return !mEntIndsRoleInstTestList.isEmpty(); |
| 4125 |
} |
| 4126 |
|
| 4127 |
|
| 4128 |
|
| 4129 |
|
| 4130 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addEntailmentIndividualsSameInstanceTestingItem(CRealizationEntailmentQueuedIndividualsSameInstanceTestingItem* queueItem) { |
| 4131 |
mEntIndsSameInstTestList.append(queueItem); |
| 4132 |
return this; |
| 4133 |
} |
| 4134 |
|
| 4135 |
QList<CRealizationEntailmentQueuedIndividualsSameInstanceTestingItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getEntailmentIndividualsSameInstanceTestingItemList() { |
| 4136 |
return &mEntIndsSameInstTestList; |
| 4137 |
} |
| 4138 |
|
| 4139 |
bool COptimizedRepresentativeKPSetOntologyRealizingItem::hasEntailmentIndividualsSameInstanceTestingItems() { |
| 4140 |
return !mEntIndsSameInstTestList.isEmpty(); |
| 4141 |
} |
| 4142 |
|
| 4143 |
|
| 4144 |
|
| 4145 |
|
| 4146 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetConceptSetCacheLabelItemData*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheConceptSetLabelItemDataHash() { |
| 4147 |
return &mRepresentativeCacheConceptSetLabelItemDataHash; |
| 4148 |
} |
| 4149 |
|
| 4150 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheConceptSetLabelItemData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, bool createIfNotExists) { |
| 4151 |
COptimizedRepresentativeKPSetConceptSetCacheLabelItemData*& itemData = mRepresentativeCacheConceptSetLabelItemDataHash[labelItem]; |
| 4152 |
if (!itemData && createIfNotExists) { |
| 4153 |
itemData = new COptimizedRepresentativeKPSetConceptSetCacheLabelItemData(labelItem); |
| 4154 |
} |
| 4155 |
return itemData; |
| 4156 |
} |
| 4157 |
|
| 4158 |
|
| 4159 |
|
| 4160 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheSingleNeighbourRoleSetLabelItemDataHash() { |
| 4161 |
return &mRepresentativeCacheSingleNeighbourRoleSetLabelItemDataHash; |
| 4162 |
} |
| 4163 |
|
| 4164 |
COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheSingleNeighbourRoleSetLabelItemData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, bool createIfNotExists) { |
| 4165 |
COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData*& itemData = mRepresentativeCacheSingleNeighbourRoleSetLabelItemDataHash[labelItem]; |
| 4166 |
if (!itemData && createIfNotExists) { |
| 4167 |
itemData = new COptimizedRepresentativeKPSetSingleNeighbourRoleSetCacheLabelItemData(); |
| 4168 |
} |
| 4169 |
return itemData; |
| 4170 |
} |
| 4171 |
|
| 4172 |
|
| 4173 |
|
| 4174 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheCombinedNeighbourRoleSetLabelItemDataHash() { |
| 4175 |
return &mRepresentativeCacheCombinedNeighbourRoleSetLabelItemDataHash; |
| 4176 |
} |
| 4177 |
|
| 4178 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheCombinedNeighbourRoleSetLabelItemData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, bool createIfNotExists) { |
| 4179 |
if (!labelItem) { |
| 4180 |
return nullptr; |
| 4181 |
} |
| 4182 |
COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData*& itemData = mRepresentativeCacheCombinedNeighbourRoleSetLabelItemDataHash[labelItem]; |
| 4183 |
if (!itemData && createIfNotExists) { |
| 4184 |
itemData = new COptimizedRepresentativeKPSetCombinedNeighbourRoleSetCacheLabelItemData(labelItem); |
| 4185 |
} |
| 4186 |
return itemData; |
| 4187 |
} |
| 4188 |
|
| 4189 |
|
| 4190 |
|
| 4191 |
QList<COptimizedKPSetRoleInstancesItem*> COptimizedRepresentativeKPSetOntologyRealizingItem::getComplexStarterCandidateRoleInstancesItems(CRole* role) { |
| 4192 |
return mComplexStarterCandidateRoleInstancesItemHash.values(role); |
| 4193 |
} |
| 4194 |
|
| 4195 |
QList<COptimizedKPSetRoleInstancesItem*> COptimizedRepresentativeKPSetOntologyRealizingItem::getInverseComplexStarterCandidateRoleInstancesItems(CRole* role) { |
| 4196 |
return mInverseComplexStarterCandidateRoleInstancesItemHash.values(role); |
| 4197 |
} |
| 4198 |
|
| 4199 |
|
| 4200 |
|
| 4201 |
QHash<CBackendRepresentativeMemoryLabelCacheItem*, COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheCombinedExistentialRoleSetLabelItemDataHash() { |
| 4202 |
return &mRepresentativeCacheCombinedExistentialRoleSetLabelItemDataHash; |
| 4203 |
} |
| 4204 |
|
| 4205 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData* COptimizedRepresentativeKPSetOntologyRealizingItem::getRepresentativeCacheCombinedExistentialRoleSetLabelItemData(CBackendRepresentativeMemoryLabelCacheItem* labelItem, bool createIfNotExists) { |
| 4206 |
if (!labelItem) { |
| 4207 |
return nullptr; |
| 4208 |
} |
| 4209 |
COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData*& itemData = mRepresentativeCacheCombinedExistentialRoleSetLabelItemDataHash[labelItem]; |
| 4210 |
if (!itemData && createIfNotExists) { |
| 4211 |
itemData = new COptimizedRepresentativeKPSetCombinedExistentialRoleSetCacheLabelItemData(labelItem); |
| 4212 |
} |
| 4213 |
return itemData; |
| 4214 |
} |
| 4215 |
|
| 4216 |
|
| 4217 |
|
| 4218 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addDataRoleCacheLabelItem(CRole* role, CBackendRepresentativeMemoryLabelCacheItem* cacheLabelItem, bool deterministic) { |
| 4219 |
if (deterministic) { |
| 4220 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>*& labelItemSet = mDataRoleDetCacheLabelItemSetHash[role]; |
| 4221 |
if (!labelItemSet) { |
| 4222 |
labelItemSet = new QSet<CBackendRepresentativeMemoryLabelCacheItem *>(); |
| 4223 |
} |
| 4224 |
labelItemSet->insert(cacheLabelItem); |
| 4225 |
} else { |
| 4226 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>*& labelItemSet = mDataRoleNonDetCacheLabelItemSetHash[role]; |
| 4227 |
if (!labelItemSet) { |
| 4228 |
labelItemSet = new QSet<CBackendRepresentativeMemoryLabelCacheItem *>(); |
| 4229 |
} |
| 4230 |
labelItemSet->insert(cacheLabelItem); |
| 4231 |
} |
| 4232 |
return this; |
| 4233 |
} |
| 4234 |
|
| 4235 |
QHash<CRole*, QSet<CBackendRepresentativeMemoryLabelCacheItem*>* >* COptimizedRepresentativeKPSetOntologyRealizingItem::getDataRoleDeterministicCacheLabelItemSetHash() { |
| 4236 |
return &mDataRoleDetCacheLabelItemSetHash; |
| 4237 |
} |
| 4238 |
|
| 4239 |
QHash<CRole*, QSet<CBackendRepresentativeMemoryLabelCacheItem*>* >* COptimizedRepresentativeKPSetOntologyRealizingItem::getDataRoleNondeterministicCacheLabelItemSetHash() { |
| 4240 |
return &mDataRoleNonDetCacheLabelItemSetHash; |
| 4241 |
} |
| 4242 |
|
| 4243 |
QSet<CBackendRepresentativeMemoryLabelCacheItem*>* COptimizedRepresentativeKPSetOntologyRealizingItem::getDataRoleCacheLabelItemSet(CRole* role, bool deterministic) { |
| 4244 |
if (deterministic) { |
| 4245 |
return mDataRoleDetCacheLabelItemSetHash.value(role); |
| 4246 |
} else { |
| 4247 |
return mDataRoleNonDetCacheLabelItemSetHash.value(role); |
| 4248 |
} |
| 4249 |
} |
| 4250 |
|
| 4251 |
|
| 4252 |
|
| 4253 |
COptimizedRepresentativeKPSetOntologyRealizingItem* COptimizedRepresentativeKPSetOntologyRealizingItem::addDataRoleNondeterministicCacheLabelItems(CRole* role) { |
| 4254 |
mDataRoleNondeterministicCacheLabelsSet.insert(role); |
| 4255 |
return this; |
| 4256 |
} |
| 4257 |
|
| 4258 |
|
| 4259 |
CBackendRepresentativeMemoryCacheReader* COptimizedRepresentativeKPSetOntologyRealizingItem::getBackendAssociationCacheReader() { |
| 4260 |
return mBackendAssocCacheReader; |
| 4261 |
} |
| 4262 |
|
| 4263 |
|
| 4264 |
}; // end namespace Realizer |
| 4265 |
|
| 4266 |
}; // end namespace Reasoner |
| 4267 |
|
| 4268 |
}; // end namespace Konclude |