Changeset 6021 for code/trunk/src/libraries/core
- Timestamp:
- Nov 4, 2009, 12:28:59 PM (15 years ago)
- Location:
- code/trunk/src/libraries/core
- Files:
-
- 2 deleted
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/CMakeLists.txt
r5929 r6021 40 40 CommandEvaluation.cc 41 41 CommandExecutor.cc 42 CommandLine .cc42 CommandLineParser.cc 43 43 ConsoleCommand.cc 44 44 ConsoleCommandCompilation.cc -
code/trunk/src/libraries/core/CommandLineParser.cc
r6014 r6021 27 27 */ 28 28 29 #include "CommandLine .h"29 #include "CommandLineParser.h" 30 30 31 31 #include <algorithm> … … 88 88 Destructor destroys all CommandLineArguments with it. 89 89 */ 90 CommandLine ::~CommandLine()91 { 92 CommandLine ::destroyAllArguments();90 CommandLineParser::~CommandLineParser() 91 { 92 CommandLineParser::destroyAllArguments(); 93 93 } 94 94 … … 97 97 Returns a unique instance (Meyers Singleton). 98 98 */ 99 CommandLine & CommandLine::_getInstance()100 { 101 static CommandLine instance;99 CommandLineParser& CommandLineParser::_getInstance() 100 { 101 static CommandLineParser instance; 102 102 return instance; 103 103 } … … 108 108 of main. Do not use before that. 109 109 */ 110 void CommandLine ::destroyAllArguments()110 void CommandLineParser::destroyAllArguments() 111 111 { 112 112 for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin(); … … 127 127 Vector of space separated strings. 128 128 */ 129 void CommandLine ::_parse(const std::vector<std::string>& arguments, bool bParsingFile)129 void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile) 130 130 { 131 131 try … … 232 232 { 233 233 COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl; 234 COUT(0) << CommandLine ::getUsageInformation() << std::endl;234 COUT(0) << CommandLineParser::getUsageInformation() << std::endl; 235 235 throw GeneralException(""); 236 236 } … … 245 245 String containing the value 246 246 */ 247 void CommandLine ::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)247 void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile) 248 248 { 249 249 std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name); … … 262 262 String containing the value 263 263 */ 264 void CommandLine ::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)264 void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile) 265 265 { 266 266 std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut); … … 271 271 } 272 272 273 std::string CommandLine ::getUsageInformation()274 { 275 CommandLine & inst = _getInstance();273 std::string CommandLineParser::getUsageInformation() 274 { 275 CommandLineParser& inst = _getInstance(); 276 276 std::ostringstream infoStr; 277 277 … … 315 315 You shold of course not call this method before the command line has been parsed. 316 316 */ 317 const CommandLineArgument* CommandLine ::getArgument(const std::string& name)317 const CommandLineArgument* CommandLineParser::getArgument(const std::string& name) 318 318 { 319 319 std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name); … … 332 332 Parses only the command line for CommandLineArguments. 333 333 */ 334 void CommandLine ::_parseCommandLine(const std::string& cmdLine)334 void CommandLineParser::_parseCommandLine(const std::string& cmdLine) 335 335 { 336 336 std::vector<std::string> args; … … 345 345 Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments. 346 346 */ 347 void CommandLine ::_parseFile()348 { 349 std::string filename = CommandLine ::getValue("optionsFile").getString();347 void CommandLineParser::_parseFile() 348 { 349 std::string filename = CommandLineParser::getValue("optionsFile").getString(); 350 350 351 351 // look for additional arguments in given file or start.ini as default -
code/trunk/src/libraries/core/CommandLineParser.h
r6014 r6021 38 38 #define SetCommandLineArgument(name, defaultValue) \ 39 39 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 40 = orxonox::CommandLine ::addArgument(#name, defaultValue, false)40 = orxonox::CommandLineParser::addArgument(#name, defaultValue, false) 41 41 #define SetCommandLineOnlyArgument(name, defaultValue) \ 42 42 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 43 = orxonox::CommandLine ::addArgument(#name, defaultValue, true)43 = orxonox::CommandLineParser::addArgument(#name, defaultValue, true) 44 44 #define SetCommandLineSwitch(name) \ 45 45 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 46 = orxonox::CommandLine ::addArgument(#name, false, false)46 = orxonox::CommandLineParser::addArgument(#name, false, false) 47 47 #define SetCommandLineOnlySwitch(name) \ 48 48 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ 49 = orxonox::CommandLine ::addArgument(#name, false, true)49 = orxonox::CommandLineParser::addArgument(#name, false, true) 50 50 51 51 … … 67 67 68 68 Retrieving an argument is possible with the getCommandLineArgument function of the 69 CommandLine class. It is a Singleton, but the public interface is static.69 CommandLineParser class. It is a Singleton, but the public interface is static. 70 70 */ 71 71 class _CoreExport CommandLineArgument 72 72 { 73 friend class CommandLine ;73 friend class CommandLineParser; 74 74 75 75 public: … … 137 137 CommandLineArgument 138 138 */ 139 class _CoreExport CommandLine 139 class _CoreExport CommandLineParser 140 140 { 141 141 public: … … 167 167 private: 168 168 //! Constructor initialises bFirstTimeParse_ with true. 169 CommandLine () : bFirstTimeParse_(true) { }169 CommandLineParser() : bFirstTimeParse_(true) { } 170 170 //! Undefined copy constructor 171 CommandLine (const CommandLine& instance);172 ~CommandLine ();173 174 static CommandLine & _getInstance();171 CommandLineParser(const CommandLineParser& instance); 172 ~CommandLineParser(); 173 174 static CommandLineParser& _getInstance(); 175 175 176 176 void _parseCommandLine(const std::string& cmdLine); … … 194 194 195 195 template <> 196 inline void CommandLine ::getValue<std::string>(const std::string& name, std::string* value)196 inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value) 197 197 { 198 198 *value = getArgument(name)->getValue().getString(); … … 209 209 */ 210 210 template <class T> 211 CommandLineArgument& CommandLine ::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)211 CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly) 212 212 { 213 213 OrxAssert(!_getInstance().existsArgument(name), -
code/trunk/src/libraries/core/Core.cc
r5929 r6021 54 54 #include "PathConfig.h" 55 55 #include "CommandExecutor.h" 56 #include "CommandLine .h"56 #include "CommandLineParser.h" 57 57 #include "ConfigFileManager.h" 58 58 #include "ConfigValueIncludes.h" … … 216 216 217 217 // Parse command line arguments AFTER the modules have been loaded (static code!) 218 CommandLine ::parseCommandLine(cmdLine);218 CommandLineParser::parseCommandLine(cmdLine); 219 219 220 220 // Set configurable paths like log, config and media … … 230 230 231 231 // Parse additional options file now that we know its path 232 CommandLine ::parseFile();232 CommandLineParser::parseFile(); 233 233 234 234 #ifdef ORXONOX_PLATFORM_WINDOWS … … 236 236 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through 237 237 // the timer though). 238 int limitToCPU = CommandLine ::getValue("limitToCPU");238 int limitToCPU = CommandLineParser::getValue("limitToCPU"); 239 239 if (limitToCPU > 0) 240 240 setThreadAffinity(static_cast<unsigned int>(limitToCPU)); … … 244 244 this->configFileManager_.reset(new ConfigFileManager()); 245 245 this->configFileManager_->setFilename(ConfigFileType::Settings, 246 CommandLine ::getValue("settingsFile").getString());246 CommandLineParser::getValue("settingsFile").getString()); 247 247 248 248 // Required as well for the config values -
code/trunk/src/libraries/core/CorePrereqs.h
r5929 r6021 116 116 class ClassTreeMaskObjectIterator; 117 117 class CommandEvaluation; 118 class CommandLine ;118 class CommandLineParser; 119 119 class CommandLineArgument; 120 120 class ConfigFile; -
code/trunk/src/libraries/core/Game.cc
r5929 r6021 44 44 #include "util/Sleep.h" 45 45 #include "util/SubString.h" 46 #include "CommandLine .h"46 #include "CommandLineParser.h" 47 47 #include "ConsoleCommand.h" 48 48 #include "Core.h" -
code/trunk/src/libraries/core/PathConfig.cc
r5929 r6021 54 54 #include "util/Debug.h" 55 55 #include "util/Exception.h" 56 #include "CommandLine .h"56 #include "CommandLineParser.h" 57 57 58 58 // Boost 1.36 has some issues with deprecated functions that have been omitted … … 186 186 187 187 // Check for data path override by the command line 188 if (!CommandLine ::getArgument("externalDataPath")->hasDefaultValue())189 externalDataPath_ = CommandLine ::getValue("externalDataPath").getString();188 if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue()) 189 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString(); 190 190 else 191 191 externalDataPath_ = specialConfig::externalDataDevDirectory; … … 224 224 225 225 // Option to put all the config and log files in a separate folder 226 if (!CommandLine ::getArgument("writingPathSuffix")->hasDefaultValue())227 { 228 std::string directory(CommandLine ::getValue("writingPathSuffix").getString());226 if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue()) 227 { 228 std::string directory(CommandLineParser::getValue("writingPathSuffix").getString()); 229 229 configPath_ = configPath_ / directory; 230 230 logPath_ = logPath_ / directory; -
code/trunk/src/libraries/core/input/InputManager.cc
r5929 r6021 48 48 #include "core/ConfigValueIncludes.h" 49 49 #include "core/ConsoleCommand.h" 50 #include "core/CommandLine .h"50 #include "core/CommandLineParser.h" 51 51 #include "core/Functor.h" 52 52 #include "core/GraphicsManager.h" … … 170 170 if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen()) 171 171 { 172 if (CommandLine ::getValue("keyboard_no_grab").getBool())172 if (CommandLineParser::getValue("keyboard_no_grab").getBool()) 173 173 paramList.insert(std::make_pair("x11_keyboard_grab", "false")); 174 174 else
Note: See TracChangeset
for help on using the changeset viewer.