Debian Codegraph @

Source/Control/Interface/CommandLine/CCommandLinePreparationTranslatorSelector.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CCommandLinePreparationTranslatorSelector.h"
22
23
24 namespace Konclude {
25
26 namespace Control {
27
28 namespace Interface {
29
30 namespace CommandLine {
31
32 CCommandLinePreparationTranslatorSelector::CCommandLinePreparationTranslatorSelector(CLoaderFactory *loaderFactory) : CLogIdentifier("::Konclude::Loader::CommandLineTranslatorSelector",this) {
33 mLoaderFactory = loaderFactory;
34 mTranslatorList.append(new COWLLinkServerComandLinePreparationTranslator(loaderFactory));
35 mTranslatorList.append(new COWLLinkFileComandLinePreparationTranslator(loaderFactory));
36 mTranslatorList.append(new CSPARQLFileComandLinePreparationTranslator(loaderFactory));
37 mTranslatorList.append(new CCLIClassClassificationComandLinePreparationTranslator(loaderFactory));
38 mTranslatorList.append(new CCLIObjectPropertyClassificationComandLinePreparationTranslator(loaderFactory));
39 mTranslatorList.append(new CCLIDataPropertyClassificationComandLinePreparationTranslator(loaderFactory));
40 mTranslatorList.append(new CCLIConsistencyComandLinePreparationTranslator(loaderFactory));
41 mTranslatorList.append(new CCLISatisfiabilityComandLinePreparationTranslator(loaderFactory));
42 mTranslatorList.append(new CCLIRealizationComandLinePreparationTranslator(loaderFactory));
43 mTranslatorList.append(new CSPARQLServerComandLinePreparationTranslator(loaderFactory));
44 mTranslatorList.append(new CHelpComandLinePreparationTranslator(loaderFactory));
45 }
46
47
48 CCommandLinePreparationTranslatorSelector::~CCommandLinePreparationTranslatorSelector() {
49 }
50
51
52
53
54
55 QStringList CCommandLinePreparationTranslatorSelector::translateArguments(const QStringList& argList) {
56 QStringList processList(argList);
57 QStringList translatedArgList;
58
59 if (!processList.isEmpty()) {
60 QString commandString = processList.first();
61 CCommandLinePreparationTranslator* translator = getCommandLinePreparationTranslator(commandString);
62
63 if (translator) {
64 translatedArgList = translator->translateArguments(processList);
65 } else {
66 QString loaderString = commandString.replace("-","");
67 if (mLoaderFactory->canCreateLoaderFromName(loaderString)) {
68 translatedArgList = argList;
69 } else {
70 translatedArgList += QString("-ConfigurableCoutLogObserverLoader");
71 translatedArgList += QString("-CommandLineTranlatorHelpLoader");
72 }
73 }
74 }
75 if (translatedArgList.isEmpty()) {
76 translatedArgList += QString("-ConfigurableCoutLogObserverLoader");
77 translatedArgList += QString("-CommandLineTranlatorHelpLoader");
78 }
79 return translatedArgList;
80 }
81
82
83
84 CCommandLinePreparationTranslator* CCommandLinePreparationTranslatorSelector::getCommandLinePreparationTranslator(const QString& commandString) {
85 CCommandLinePreparationTranslator* selectedTranslator = nullptr;
86
87 for (QList<CCommandLinePreparationTranslator*>::const_iterator it = mTranslatorList.constBegin(), itEnd = mTranslatorList.constEnd(); !selectedTranslator && it != itEnd; ++it) {
88 CCommandLinePreparationTranslator* translator = (*it);
89 if (translator && translator->canTranslate(commandString)) {
90 selectedTranslator = translator;
91 }
92 }
93
94 return selectedTranslator;
95 }
96
97
98
99 }; // end namespace CommandLine
100
101 }; // end namespace Interface
102
103 }; // end namespace Control
104
105 }; // end namespace Konclude