1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qbs. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 #include "commandlineoptionpool.h" 40 41 namespace qbs { 42 ~CommandLineOptionPool()43CommandLineOptionPool::~CommandLineOptionPool() 44 { 45 qDeleteAll(m_options); 46 } 47 getOption(CommandLineOption::Type type) const48CommandLineOption *CommandLineOptionPool::getOption(CommandLineOption::Type type) const 49 { 50 CommandLineOption *& option = m_options[type]; 51 if (!option) { 52 switch (type) { 53 case CommandLineOption::FileOptionType: 54 option = new FileOption; 55 break; 56 case CommandLineOption::BuildDirectoryOptionType: 57 option = new BuildDirectoryOption; 58 break; 59 case CommandLineOption::LogLevelOptionType: 60 option = new LogLevelOption; 61 break; 62 case CommandLineOption::VerboseOptionType: 63 option = new VerboseOption; 64 break; 65 case CommandLineOption::QuietOptionType: 66 option = new QuietOption; 67 break; 68 case CommandLineOption::JobsOptionType: 69 option = new JobsOption; 70 break; 71 case CommandLineOption::KeepGoingOptionType: 72 option = new KeepGoingOption; 73 break; 74 case CommandLineOption::DryRunOptionType: 75 option = new DryRunOption; 76 break; 77 case CommandLineOption::ForceProbesOptionType: 78 option = new ForceProbesOption; 79 break; 80 case CommandLineOption::ShowProgressOptionType: 81 option = new ShowProgressOption; 82 break; 83 case CommandLineOption::ChangedFilesOptionType: 84 option = new ChangedFilesOption; 85 break; 86 case CommandLineOption::ProductsOptionType: 87 option = new ProductsOption; 88 break; 89 case CommandLineOption::NoInstallOptionType: 90 option = new NoInstallOption; 91 break; 92 case CommandLineOption::InstallRootOptionType: 93 option = new InstallRootOption; 94 break; 95 case CommandLineOption::RemoveFirstOptionType: 96 option = new RemoveFirstOption; 97 break; 98 case CommandLineOption::NoBuildOptionType: 99 option = new NoBuildOption; 100 break; 101 case CommandLineOption::ForceTimestampCheckOptionType: 102 option = new ForceTimeStampCheckOption; 103 break; 104 case CommandLineOption::ForceOutputCheckOptionType: 105 option = new ForceOutputCheckOption; 106 break; 107 case CommandLineOption::BuildNonDefaultOptionType: 108 option = new BuildNonDefaultOption; 109 break; 110 case CommandLineOption::LogTimeOptionType: 111 option = new LogTimeOption; 112 break; 113 case CommandLineOption::CommandEchoModeOptionType: 114 option = new CommandEchoModeOption; 115 break; 116 case CommandLineOption::SettingsDirOptionType: 117 option = new SettingsDirOption; 118 break; 119 case CommandLineOption::JobLimitsOptionType: 120 option = new JobLimitsOption; 121 break; 122 case CommandLineOption::RespectProjectJobLimitsOptionType: 123 option = new RespectProjectJobLimitsOption; 124 break; 125 case CommandLineOption::GeneratorOptionType: 126 option = new GeneratorOption; 127 break; 128 case CommandLineOption::WaitLockOptionType: 129 option = new WaitLockOption; 130 break; 131 case CommandLineOption::DisableFallbackProviderType: 132 option = new DisableFallbackProviderOption; 133 break; 134 case CommandLineOption::RunEnvConfigOptionType: 135 option = new RunEnvConfigOption; 136 break; 137 default: 138 qFatal("Unknown option type %d", type); 139 } 140 } 141 return option; 142 } 143 fileOption() const144FileOption *CommandLineOptionPool::fileOption() const 145 { 146 return static_cast<FileOption *>(getOption(CommandLineOption::FileOptionType)); 147 } 148 buildDirectoryOption() const149BuildDirectoryOption *CommandLineOptionPool::buildDirectoryOption() const 150 { 151 return static_cast<BuildDirectoryOption *>(getOption(CommandLineOption::BuildDirectoryOptionType)); 152 } 153 logLevelOption() const154LogLevelOption *CommandLineOptionPool::logLevelOption() const 155 { 156 return static_cast<LogLevelOption *>(getOption(CommandLineOption::LogLevelOptionType)); 157 } 158 verboseOption() const159VerboseOption *CommandLineOptionPool::verboseOption() const 160 { 161 return static_cast<VerboseOption *>(getOption(CommandLineOption::VerboseOptionType)); 162 } 163 quietOption() const164QuietOption *CommandLineOptionPool::quietOption() const 165 { 166 return static_cast<QuietOption *>(getOption(CommandLineOption::QuietOptionType)); 167 } 168 showProgressOption() const169ShowProgressOption *CommandLineOptionPool::showProgressOption() const 170 { 171 return static_cast<ShowProgressOption *>(getOption(CommandLineOption::ShowProgressOptionType)); 172 } 173 dryRunOption() const174DryRunOption *CommandLineOptionPool::dryRunOption() const 175 { 176 return static_cast<DryRunOption *>(getOption(CommandLineOption::DryRunOptionType)); 177 } 178 forceProbesOption() const179ForceProbesOption *CommandLineOptionPool::forceProbesOption() const 180 { 181 return static_cast<ForceProbesOption *>(getOption(CommandLineOption::ForceProbesOptionType)); 182 } 183 changedFilesOption() const184ChangedFilesOption *CommandLineOptionPool::changedFilesOption() const 185 { 186 return static_cast<ChangedFilesOption *>(getOption(CommandLineOption::ChangedFilesOptionType)); 187 } 188 keepGoingOption() const189KeepGoingOption *CommandLineOptionPool::keepGoingOption() const 190 { 191 return static_cast<KeepGoingOption *>(getOption(CommandLineOption::KeepGoingOptionType)); 192 } 193 jobsOption() const194JobsOption *CommandLineOptionPool::jobsOption() const 195 { 196 return static_cast<JobsOption *>(getOption(CommandLineOption::JobsOptionType)); 197 } 198 productsOption() const199ProductsOption *CommandLineOptionPool::productsOption() const 200 { 201 return static_cast<ProductsOption *>(getOption(CommandLineOption::ProductsOptionType)); 202 } 203 noInstallOption() const204NoInstallOption *CommandLineOptionPool::noInstallOption() const 205 { 206 return static_cast<NoInstallOption *>(getOption(CommandLineOption::NoInstallOptionType)); 207 } 208 installRootOption() const209InstallRootOption *CommandLineOptionPool::installRootOption() const 210 { 211 return static_cast<InstallRootOption *>(getOption(CommandLineOption::InstallRootOptionType)); 212 } 213 removeFirstoption() const214RemoveFirstOption *CommandLineOptionPool::removeFirstoption() const 215 { 216 return static_cast<RemoveFirstOption *>(getOption(CommandLineOption::RemoveFirstOptionType)); 217 } 218 noBuildOption() const219NoBuildOption *CommandLineOptionPool::noBuildOption() const 220 { 221 return static_cast<NoBuildOption *>(getOption(CommandLineOption::NoBuildOptionType)); 222 } 223 forceTimestampCheckOption() const224ForceTimeStampCheckOption *CommandLineOptionPool::forceTimestampCheckOption() const 225 { 226 return static_cast<ForceTimeStampCheckOption *>( 227 getOption(CommandLineOption::ForceTimestampCheckOptionType)); 228 } 229 forceOutputCheckOption() const230ForceOutputCheckOption *CommandLineOptionPool::forceOutputCheckOption() const 231 { 232 return static_cast<ForceOutputCheckOption *>( 233 getOption(CommandLineOption::ForceOutputCheckOptionType)); 234 } 235 buildNonDefaultOption() const236BuildNonDefaultOption *CommandLineOptionPool::buildNonDefaultOption() const 237 { 238 return static_cast<BuildNonDefaultOption *>( 239 getOption(CommandLineOption::BuildNonDefaultOptionType)); 240 } 241 logTimeOption() const242LogTimeOption *CommandLineOptionPool::logTimeOption() const 243 { 244 return static_cast<LogTimeOption *>(getOption(CommandLineOption::LogTimeOptionType)); 245 } 246 commandEchoModeOption() const247CommandEchoModeOption *CommandLineOptionPool::commandEchoModeOption() const 248 { 249 return static_cast<CommandEchoModeOption *>( 250 getOption(CommandLineOption::CommandEchoModeOptionType)); 251 } 252 settingsDirOption() const253SettingsDirOption *CommandLineOptionPool::settingsDirOption() const 254 { 255 return static_cast<SettingsDirOption *>(getOption(CommandLineOption::SettingsDirOptionType)); 256 } 257 jobLimitsOption() const258JobLimitsOption *CommandLineOptionPool::jobLimitsOption() const 259 { 260 return static_cast<JobLimitsOption *>(getOption(CommandLineOption::JobLimitsOptionType)); 261 } 262 respectProjectJobLimitsOption() const263RespectProjectJobLimitsOption *CommandLineOptionPool::respectProjectJobLimitsOption() const 264 { 265 return static_cast<RespectProjectJobLimitsOption *>( 266 getOption(CommandLineOption::RespectProjectJobLimitsOptionType)); 267 } 268 generatorOption() const269GeneratorOption *CommandLineOptionPool::generatorOption() const 270 { 271 return static_cast<GeneratorOption *>(getOption(CommandLineOption::GeneratorOptionType)); 272 } 273 waitLockOption() const274WaitLockOption *CommandLineOptionPool::waitLockOption() const 275 { 276 return static_cast<WaitLockOption *>(getOption(CommandLineOption::WaitLockOptionType)); 277 } 278 disableFallbackProviderOption() const279DisableFallbackProviderOption *CommandLineOptionPool::disableFallbackProviderOption() const 280 { 281 return static_cast<DisableFallbackProviderOption *>( 282 getOption(CommandLineOption::DisableFallbackProviderType)); 283 } 284 runEnvConfigOption() const285RunEnvConfigOption *CommandLineOptionPool::runEnvConfigOption() const 286 { 287 return static_cast<RunEnvConfigOption *>(getOption(CommandLineOption::RunEnvConfigOptionType)); 288 } 289 290 } // namespace qbs 291