| 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 "CDefaultCommanderInitializationFactory.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Control { |
| 27 |
|
| 28 |
namespace Command { |
| 29 |
|
| 30 |
|
| 31 |
CDefaultCommanderInitializationFactory::CDefaultCommanderInitializationFactory(CReasonerManager *useReasonerManager, CClassificationManager *useClassificationManager, COntologyRevisionManager *useOntologyRevisionManager) { |
| 32 |
useReasonerMan = useReasonerManager; |
| 33 |
useClassificationMan = useClassificationManager; |
| 34 |
useOntRevMan = useOntologyRevisionManager; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
CDefaultCommanderInitializationFactory::~CDefaultCommanderInitializationFactory() { |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
CReasonerManager *CDefaultCommanderInitializationFactory::createReasonerManager(CConfigurationProvider *configProvider) { |
| 43 |
|
| 44 |
CReasonerManager *reasonerManager = 0; |
| 45 |
bool generatedReasoner = false; |
| 46 |
|
| 47 |
if (useReasonerMan) { |
| 48 |
reasonerManager = useReasonerMan; |
| 49 |
generatedReasoner = true; |
| 50 |
} |
| 51 |
|
| 52 |
CConfigurationBase *config = 0; |
| 53 |
if (configProvider) { |
| 54 |
config = configProvider->getCurrentConfiguration(); |
| 55 |
} |
| 56 |
|
| 57 |
if (config) { |
| 58 |
CConfigData *confData = 0; |
| 59 |
|
| 60 |
if (!generatedReasoner) { |
| 61 |
confData = config->getRelatedConfigChange("Konclude.Execution.DefaultReasonerManager"); |
| 62 |
if (confData) { |
| 63 |
QString reasonerString = confData->getString(); |
| 64 |
if (reasonerString == "ReasonerManager") { |
| 65 |
reasonerManager = new CReasonerManagerThread(); |
| 66 |
generatedReasoner = true; |
| 67 |
} else if (reasonerString == "ASAnalyseReasonerManager") { |
| 68 |
reasonerManager = new CAnalyseReasonerManager(); |
| 69 |
generatedReasoner = true; |
| 70 |
} else if (reasonerString == "ASExperimentalReasonerManager") { |
| 71 |
reasonerManager = new CExperimentalReasonerManager(); |
| 72 |
generatedReasoner = true; |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
if (!generatedReasoner) { |
| 79 |
reasonerManager = new CReasonerManagerThread(); |
| 80 |
generatedReasoner = true; |
| 81 |
} |
| 82 |
return reasonerManager; |
| 83 |
} |
| 84 |
|
| 85 |
CClassificationManager *CDefaultCommanderInitializationFactory::createClassificationManager(CConfigurationProvider *configProvider) { |
| 86 |
CClassificationManager *classificationManager = 0; |
| 87 |
bool generatedClassification = false; |
| 88 |
|
| 89 |
if (useClassificationMan) { |
| 90 |
classificationManager = useClassificationMan; |
| 91 |
generatedClassification = true; |
| 92 |
} |
| 93 |
|
| 94 |
CConfigurationBase *config = 0; |
| 95 |
if (configProvider) { |
| 96 |
config = configProvider->getCurrentConfiguration(); |
| 97 |
} |
| 98 |
|
| 99 |
if (!generatedClassification) { |
| 100 |
classificationManager = new CClassificationManager(); |
| 101 |
generatedClassification = true; |
| 102 |
} |
| 103 |
|
| 104 |
return classificationManager; |
| 105 |
} |
| 106 |
|
| 107 |
COntologyRevisionManager *CDefaultCommanderInitializationFactory::createOntologyRevisionManager(CConfigurationProvider *configProvider) { |
| 108 |
COntologyRevisionManager *ontRevManager = 0; |
| 109 |
bool generatedOntRevMan = false; |
| 110 |
|
| 111 |
if (useOntRevMan) { |
| 112 |
ontRevManager = useOntRevMan; |
| 113 |
generatedOntRevMan = true; |
| 114 |
} |
| 115 |
|
| 116 |
CConfigurationBase *config = 0; |
| 117 |
if (configProvider) { |
| 118 |
config = configProvider->getCurrentConfiguration(); |
| 119 |
} |
| 120 |
|
| 121 |
if (!generatedOntRevMan) { |
| 122 |
CConfigurationBasedOntologyRevisionPersistencerFactory* persistencerFactory = new CConfigurationBasedOntologyRevisionPersistencerFactory(config); |
| 123 |
ontRevManager = new CSPOntologyRevisionManager(persistencerFactory->createOntologyRevisionPersistencer()); |
| 124 |
delete persistencerFactory; |
| 125 |
generatedOntRevMan = true; |
| 126 |
} |
| 127 |
|
| 128 |
return ontRevManager; |
| 129 |
} |
| 130 |
|
| 131 |
CCommanderInitializationFactory *CDefaultCommanderInitializationFactory::initializeReasonerManager(CReasonerManager *reasonerManager, CConfigurationProvider *configProvider) { |
| 132 |
reasonerManager->initializeManager(configProvider); |
| 133 |
return this; |
| 134 |
} |
| 135 |
|
| 136 |
CCommanderInitializationFactory *CDefaultCommanderInitializationFactory::initializeClassificationManager(CClassificationManager *classificationManager, CConfigurationProvider *configProvider) { |
| 137 |
CReasonerManager *reasonerManager = CConfigManagerReader::readReasonerManagerConfig(configProvider); |
| 138 |
CSubsumptionClassifierFactory *subsumpFactory = new CConfigDependedSubsumptionClassifierFactory(reasonerManager); |
| 139 |
classificationManager->initializeManager(subsumpFactory,configProvider); |
| 140 |
return this; |
| 141 |
} |
| 142 |
|
| 143 |
CCommanderInitializationFactory *CDefaultCommanderInitializationFactory::initializeOntologyRevisionManager(COntologyRevisionManager *ontologyRevisionManager, CConfigurationProvider *configProvider) { |
| 144 |
ontologyRevisionManager->initializeManager(configProvider); |
| 145 |
return this; |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
}; // end namespace Command |
| 151 |
|
| 152 |
}; // end namespace Control |
| 153 |
|
| 154 |
}; // end namespace Konclude |