| 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 "CConcreteOntology.h" |
| 22 |
#include "CIndividualNameABoxVectorTriplesAccessorResolver.h" |
| 23 |
|
| 24 |
|
| 25 |
namespace Konclude { |
| 26 |
|
| 27 |
namespace Reasoner { |
| 28 |
|
| 29 |
namespace Ontology { |
| 30 |
|
| 31 |
|
| 32 |
CConcreteOntology::CConcreteOntology(CConfigurationBase* configuration) { |
| 33 |
mStructSumm = nullptr; |
| 34 |
mStringMapping = nullptr; |
| 35 |
mDataBoxes = nullptr; |
| 36 |
mLoadData = nullptr; |
| 37 |
mBuildData = nullptr; |
| 38 |
mTax = nullptr; |
| 39 |
mConsistence = nullptr; |
| 40 |
mAxiomSet = nullptr; |
| 41 |
mConceptCyclesData = nullptr; |
| 42 |
mPrecomputation = nullptr; |
| 43 |
mProcessingSteps = nullptr; |
| 44 |
|
| 45 |
mConfiguration = configuration; |
| 46 |
|
| 47 |
mOntologyTriplesData = new COntologyTriplesData(); |
| 48 |
mClassification = new CClassification(); |
| 49 |
mPrecomputation = new CPrecomputation(); |
| 50 |
mPreprocessing = new CPreprocessing(); |
| 51 |
mRealization = new CRealization(); |
| 52 |
mOntConctext = new CConcreteOntologyContextBase(); |
| 53 |
mDataBoxes = CObjectParameterizingAllocator< COntologyDataBoxes,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 54 |
mLoadData = CObjectParameterizingAllocator< COntologyLoadData, CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext), mOntConctext); |
| 55 |
mStringMapping = CObjectParameterizingAllocator< COntologyStringMapping,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 56 |
mStructSumm = CObjectParameterizingAllocator< COntologyStructureSummary,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 57 |
mBuildData = CObjectParameterizingAllocator< COntologyBuildData,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 58 |
mConceptCyclesData = CObjectParameterizingAllocator< COntologyCoreConceptCyclesData,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 59 |
mProcessingSteps = CObjectParameterizingAllocator< COntologyProcessingSteps,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 60 |
mIncRevisionData = CObjectParameterizingAllocator< COntologyIncrementalRevisionData,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 61 |
mIncRevisionData->setBasementOntology(this); |
| 62 |
|
| 63 |
mIndividualNameResolver = new CIndividualNameABoxVectorTriplesAccessorResolver(this); |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
CConcreteOntology::CConcreteOntology(CConcreteOntology* refOntology, CConfigurationBase* configuration) { |
| 69 |
mStructSumm = nullptr; |
| 70 |
mStringMapping = nullptr; |
| 71 |
mDataBoxes = nullptr; |
| 72 |
mLoadData = nullptr; |
| 73 |
mBuildData = nullptr; |
| 74 |
mTax = nullptr; |
| 75 |
mConsistence = nullptr; |
| 76 |
mAxiomSet = nullptr; |
| 77 |
mConceptCyclesData = nullptr; |
| 78 |
mPrecomputation = nullptr; |
| 79 |
mProcessingSteps = nullptr; |
| 80 |
|
| 81 |
mConfiguration = configuration; |
| 82 |
|
| 83 |
mOntologyTriplesData = new COntologyTriplesData(); |
| 84 |
mClassification = new CClassification(); |
| 85 |
mPrecomputation = new CPrecomputation(); |
| 86 |
mPreprocessing = new CPreprocessing(); |
| 87 |
mRealization = new CRealization(); |
| 88 |
mOntConctext = new CConcreteOntologyContextBase(); |
| 89 |
mDataBoxes = CObjectParameterizingAllocator< COntologyDataBoxes,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 90 |
mLoadData = CObjectParameterizingAllocator< COntologyLoadData, CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext), mOntConctext); |
| 91 |
mStringMapping = CObjectParameterizingAllocator< COntologyStringMapping, CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext), mOntConctext); |
| 92 |
mStructSumm = CObjectParameterizingAllocator< COntologyStructureSummary,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 93 |
mBuildData = CObjectParameterizingAllocator< COntologyBuildData,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 94 |
mConceptCyclesData = CObjectParameterizingAllocator< COntologyCoreConceptCyclesData,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 95 |
mProcessingSteps = CObjectParameterizingAllocator< COntologyProcessingSteps,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 96 |
mIncRevisionData = CObjectParameterizingAllocator< COntologyIncrementalRevisionData,CBoxContext* >::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mOntConctext),mOntConctext); |
| 97 |
|
| 98 |
mIndividualNameResolver = new CIndividualNameABoxVectorTriplesAccessorResolver(this); |
| 99 |
|
| 100 |
if (refOntology) { |
| 101 |
referenceOntology(refOntology); |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
CConcreteOntology::~CConcreteOntology() { |
| 107 |
COPADestroyAndRelease(mDataBoxes, CContext::getMemoryAllocationManager(mOntConctext)); |
| 108 |
COPADestroyAndRelease(mLoadData, CContext::getMemoryAllocationManager(mOntConctext)); |
| 109 |
COPADestroyAndRelease(mStructSumm,CContext::getMemoryAllocationManager(mOntConctext)); |
| 110 |
COPADestroyAndRelease(mStringMapping,CContext::getMemoryAllocationManager(mOntConctext)); |
| 111 |
COPADestroyAndRelease(mBuildData,CContext::getMemoryAllocationManager(mOntConctext)); |
| 112 |
COPADestroyAndRelease(mConceptCyclesData,CContext::getMemoryAllocationManager(mOntConctext)); |
| 113 |
COPADestroyAndRelease(mProcessingSteps,CContext::getMemoryAllocationManager(mOntConctext)); |
| 114 |
COPADestroyAndRelease(mIncRevisionData,CContext::getMemoryAllocationManager(mOntConctext)); |
| 115 |
|
| 116 |
delete mIndividualNameResolver; |
| 117 |
delete mOntConctext; |
| 118 |
delete mConsistence; |
| 119 |
delete mClassification; |
| 120 |
delete mPrecomputation; |
| 121 |
delete mPreprocessing; |
| 122 |
delete mRealization; |
| 123 |
delete mOntologyTriplesData; |
| 124 |
} |
| 125 |
|
| 126 |
CConfigurationBase* CConcreteOntology::getConfiguration() { |
| 127 |
return mConfiguration; |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
CConcreteOntology* CConcreteOntology::referenceOntology(CConcreteOntology* ontology) { |
| 132 |
mLoadData->referenceLoadData(ontology->mLoadData); |
| 133 |
mDataBoxes->referenceDataBoxes(ontology->mDataBoxes); |
| 134 |
mStringMapping->referenceStringMapping(ontology->mStringMapping); |
| 135 |
mBuildData->referenceBuildData(ontology->mBuildData); |
| 136 |
mStructSumm->referenceStructureSummary(ontology->mStructSumm); |
| 137 |
mIncRevisionData->referenceIncrementalRevision(ontology->mIncRevisionData); |
| 138 |
mOntologyTriplesData->referenceTriplesData(ontology->mOntologyTriplesData); |
| 139 |
mIncRevisionData->setPreviousOntologyVersion(ontology); |
| 140 |
return this; |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
CABox* CConcreteOntology::getABox() { |
| 145 |
return mDataBoxes->getABox(); |
| 146 |
} |
| 147 |
|
| 148 |
CTBox* CConcreteOntology::getTBox() { |
| 149 |
return mDataBoxes->getTBox(); |
| 150 |
} |
| 151 |
|
| 152 |
CRBox* CConcreteOntology::getRBox() { |
| 153 |
return mDataBoxes->getRBox(); |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
CConcept* CConcreteOntology::getConcept(const QString& className) { |
| 158 |
CConcept* concept = nullptr; |
| 159 |
CMAPPINGHASH<CStringRefStringHasher,CConcept*>* classNameConceptMappingHash = mStringMapping->getClassNameConceptMappingHash(false); |
| 160 |
if (classNameConceptMappingHash) { |
| 161 |
concept = classNameConceptMappingHash->value(className,nullptr); |
| 162 |
} |
| 163 |
return concept; |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
CRole* CConcreteOntology::getRole(const QString& propertyName) { |
| 168 |
CRole* role = nullptr; |
| 169 |
CMAPPINGHASH<CStringRefStringHasher,CRole*>* propertyNameRoleMappingHash = mStringMapping->getPropertyNameRoleMappingHash(false); |
| 170 |
if (propertyNameRoleMappingHash) { |
| 171 |
role = propertyNameRoleMappingHash->value(propertyName,nullptr); |
| 172 |
} |
| 173 |
return role; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
CIndividual* CConcreteOntology::getIndividual(const QString& indiName) { |
| 178 |
CIndividual* indi = nullptr; |
| 179 |
CMAPPINGHASH<CStringRefStringHasher,CIndividual*>* indiNameIndiMappingHash = mStringMapping->getIndividualNameIndividualMappingHash(false); |
| 180 |
if (indiNameIndiMappingHash) { |
| 181 |
indi = indiNameIndiMappingHash->value(indiName,nullptr); |
| 182 |
} |
| 183 |
return indi; |
| 184 |
} |
| 185 |
|
| 186 |
|
| 187 |
CConcreteOntology* CConcreteOntology::setConceptTaxonomy(CTaxonomy *taxonomy) { |
| 188 |
mTax = taxonomy; |
| 189 |
return this; |
| 190 |
} |
| 191 |
|
| 192 |
CTaxonomy *CConcreteOntology::getConceptTaxonomy() { |
| 193 |
return mTax; |
| 194 |
} |
| 195 |
|
| 196 |
bool CConcreteOntology::hasConceptTaxonomy() { |
| 197 |
return mTax != nullptr; |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
CConsistence* CConcreteOntology::getConsistence() { |
| 202 |
return mConsistence; |
| 203 |
} |
| 204 |
|
| 205 |
bool CConcreteOntology::hasConsistence() { |
| 206 |
return mConsistence != nullptr; |
| 207 |
} |
| 208 |
|
| 209 |
CConcreteOntology *CConcreteOntology::setConsistence(CConsistence *consistence) { |
| 210 |
mConsistence = consistence; |
| 211 |
return this; |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
CClassification* CConcreteOntology::getClassification() { |
| 217 |
return mClassification; |
| 218 |
} |
| 219 |
|
| 220 |
bool CConcreteOntology::hasClassification() { |
| 221 |
return mClassification != nullptr; |
| 222 |
} |
| 223 |
|
| 224 |
CConcreteOntology *CConcreteOntology::setClassification(CClassification *classification) { |
| 225 |
mClassification = classification; |
| 226 |
return this; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
CPrecomputation* CConcreteOntology::getPrecomputation() { |
| 231 |
return mPrecomputation; |
| 232 |
} |
| 233 |
|
| 234 |
bool CConcreteOntology::hasPrecomputation() { |
| 235 |
return mPrecomputation != nullptr; |
| 236 |
} |
| 237 |
|
| 238 |
CConcreteOntology* CConcreteOntology::setPrecomputation(CPrecomputation* precomputation) { |
| 239 |
mPrecomputation = precomputation; |
| 240 |
return this; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
CPreprocessing* CConcreteOntology::getPreprocessing() { |
| 245 |
return mPreprocessing; |
| 246 |
} |
| 247 |
|
| 248 |
bool CConcreteOntology::hasPreprocessing() { |
| 249 |
return mPreprocessing != nullptr; |
| 250 |
} |
| 251 |
|
| 252 |
CConcreteOntology* CConcreteOntology::setPreprocessing(CPreprocessing* preprocessing) { |
| 253 |
mPreprocessing = preprocessing; |
| 254 |
return this; |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
CRealization* CConcreteOntology::getRealization() { |
| 260 |
return mRealization; |
| 261 |
} |
| 262 |
|
| 263 |
bool CConcreteOntology::hasRealization() { |
| 264 |
return mRealization != nullptr; |
| 265 |
} |
| 266 |
|
| 267 |
CConcreteOntology* CConcreteOntology::setRealization(CRealization* realization) { |
| 268 |
mRealization = realization; |
| 269 |
return this; |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
COntologyStructureSummary *CConcreteOntology::getStructureSummary() { |
| 274 |
return mStructSumm; |
| 275 |
} |
| 276 |
|
| 277 |
CConcreteOntology *CConcreteOntology::setStructureSummary(COntologyStructureSummary *structureSummary) { |
| 278 |
mStructSumm = structureSummary; |
| 279 |
return this; |
| 280 |
} |
| 281 |
|
| 282 |
COntologyDataBoxes *CConcreteOntology::getDataBoxes() { |
| 283 |
return mDataBoxes; |
| 284 |
} |
| 285 |
|
| 286 |
CConcreteOntology *CConcreteOntology::setDataBoxes(COntologyDataBoxes *dataBoxes) { |
| 287 |
mDataBoxes = dataBoxes; |
| 288 |
return this; |
| 289 |
} |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
COntologyLoadData* CConcreteOntology::getLoadData() { |
| 295 |
return mLoadData; |
| 296 |
} |
| 297 |
|
| 298 |
CConcreteOntology *CConcreteOntology::setLoadData(COntologyLoadData* loadData) { |
| 299 |
mLoadData = loadData; |
| 300 |
return this; |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
COntologyStringMapping *CConcreteOntology::getStringMapping() { |
| 308 |
return mStringMapping; |
| 309 |
} |
| 310 |
|
| 311 |
CConcreteOntology *CConcreteOntology::setStringMapping(COntologyStringMapping *stringMapping) { |
| 312 |
mStringMapping = stringMapping; |
| 313 |
return this; |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
COntologyContext* CConcreteOntology::getOntologyContext() { |
| 318 |
return mOntConctext; |
| 319 |
} |
| 320 |
|
| 321 |
COntologyBuildData *CConcreteOntology::getBuildData() { |
| 322 |
return mBuildData; |
| 323 |
} |
| 324 |
|
| 325 |
CConcreteOntology *CConcreteOntology::setBuildData(COntologyBuildData *buildData) { |
| 326 |
mBuildData = buildData; |
| 327 |
return this; |
| 328 |
} |
| 329 |
|
| 330 |
COntologyCoreConceptCyclesData* CConcreteOntology::getCoreConceptCyclesData() { |
| 331 |
return mConceptCyclesData; |
| 332 |
} |
| 333 |
|
| 334 |
CConcreteOntology* CConcreteOntology::setCoreConceptCyclesData(COntologyCoreConceptCyclesData* cyclesData) { |
| 335 |
mConceptCyclesData = cyclesData; |
| 336 |
return this; |
| 337 |
} |
| 338 |
|
| 339 |
COntologyProcessingSteps* CConcreteOntology::getProcessingSteps() { |
| 340 |
return mProcessingSteps; |
| 341 |
} |
| 342 |
|
| 343 |
CConcreteOntology* CConcreteOntology::setProcessingSteps(COntologyProcessingSteps* stepData) { |
| 344 |
mProcessingSteps = stepData; |
| 345 |
return this; |
| 346 |
} |
| 347 |
|
| 348 |
COntologyTriplesData* CConcreteOntology::getOntologyTriplesData() { |
| 349 |
return mOntologyTriplesData; |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
COntologyIncrementalRevisionData* CConcreteOntology::getIncrementalRevisionData() { |
| 354 |
return mIncRevisionData; |
| 355 |
} |
| 356 |
|
| 357 |
CConcreteOntology* CConcreteOntology::setIncrementalRevisionData(COntologyIncrementalRevisionData* incRevData) { |
| 358 |
mIncRevisionData = incRevData; |
| 359 |
return this; |
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
CIndividualNameResolver* CConcreteOntology::getIndividualNameResolver() { |
| 364 |
return mIndividualNameResolver; |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
}; // end namespace Ontology |
| 369 |
|
| 370 |
}; // end namespace Reasoner |
| 371 |
|
| 372 |
}; // end namespace Konclude |