Changeset 6021 for code/trunk
- Timestamp:
- Nov 4, 2009, 12:28:59 PM (15 years ago)
- Location:
- code/trunk/src
- Files:
-
- 2 deleted
- 12 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 -
code/trunk/src/orxonox/LevelManager.cc
r5929 r6021 32 32 #include <OgreResourceGroupManager.h> 33 33 34 #include "core/CommandLine .h"34 #include "core/CommandLineParser.h" 35 35 #include "core/ConfigValueIncludes.h" 36 36 #include "core/CoreIncludes.h" … … 53 53 54 54 // check override 55 if (!CommandLine ::getArgument("level")->hasDefaultValue())55 if (!CommandLineParser::getArgument("level")->hasDefaultValue()) 56 56 { 57 ModifyConfigValue(defaultLevelName_, tset, CommandLine ::getValue("level").getString());57 ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").getString()); 58 58 } 59 59 } -
code/trunk/src/orxonox/Main.cc
r5929 r6021 36 36 #include "OrxonoxPrereqs.h" 37 37 38 #include "core/CommandLine .h"38 #include "core/CommandLineParser.h" 39 39 #include "core/Game.h" 40 40 #include "core/LuaState.h" … … 76 76 77 77 // Some development hacks (not really, but in the future, this calls won't make sense anymore) 78 if (CommandLine ::getValue("standalone").getBool())78 if (CommandLineParser::getValue("standalone").getBool()) 79 79 Game::getInstance().requestStates("graphics, standalone, level"); 80 else if (CommandLine ::getValue("server").getBool())80 else if (CommandLineParser::getValue("server").getBool()) 81 81 Game::getInstance().requestStates("graphics, server, level"); 82 else if (CommandLine ::getValue("client").getBool())82 else if (CommandLineParser::getValue("client").getBool()) 83 83 Game::getInstance().requestStates("graphics, client, level"); 84 else if (CommandLine ::getValue("dedicated").getBool())84 else if (CommandLineParser::getValue("dedicated").getBool()) 85 85 Game::getInstance().requestStates("dedicated, level"); 86 else if (CommandLine ::getValue("dedicatedClient").getBool())86 else if (CommandLineParser::getValue("dedicatedClient").getBool()) 87 87 Game::getInstance().requestStates("dedicatedClient, level"); 88 else if (CommandLine ::getValue("console").getBool())88 else if (CommandLineParser::getValue("console").getBool()) 89 89 Game::getInstance().requestStates("ioConsole"); 90 90 else -
code/trunk/src/orxonox/gamestates/GSClient.cc
r5929 r6021 31 31 #include "util/Clock.h" 32 32 #include "util/Exception.h" 33 #include "core/CommandLine .h"33 #include "core/CommandLineParser.h" 34 34 #include "core/Game.h" 35 35 #include "core/GameMode.h" … … 56 56 GameMode::setIsClient(true); 57 57 58 this->client_ = new Client(CommandLine ::getValue("ip").getString(), CommandLine::getValue("port"));58 this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLineParser::getValue("port")); 59 59 60 60 if(!client_->establishConnection()) -
code/trunk/src/orxonox/gamestates/GSDedicated.cc
r5929 r6021 36 36 #include "util/Debug.h" 37 37 #include "util/Sleep.h" 38 #include "core/CommandLine .h"38 #include "core/CommandLineParse.h" 39 39 #include "core/CommandExecutor.h" 40 40 #include "core/Game.h" … … 81 81 #endif 82 82 83 this->server_ = new Server(CommandLine ::getValue("port"));83 this->server_ = new Server(CommandLineParser::getValue("port")); 84 84 COUT(0) << "Loading scene in server mode" << std::endl; 85 85 … … 91 91 this->server_->close(); 92 92 delete this->server_; 93 93 94 94 closeThread_ = true; 95 95 #ifdef ORXONOX_PLATFORM_UNIX … … 138 138 escapeChar = 2; 139 139 continue; 140 140 } 141 141 else if ( escapeChar == 2 ) 142 142 { -
code/trunk/src/orxonox/gamestates/GSDedicatedClient.cc
r5929 r6021 37 37 #include "util/Exception.h" 38 38 #include "util/Sleep.h" 39 #include "core/CommandLine .h"39 #include "core/CommandLineParser.h" 40 40 #include "core/CommandExecutor.h" 41 41 #include "core/Game.h" … … 80 80 #endif 81 81 82 this->client_ = new Client(CommandLine ::getValue("ip").getString(), CommandLine::getValue("port"));82 this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLine::getValue("port")); 83 83 COUT(0) << "Loading scene in client mode" << std::endl; 84 84 … … 93 93 void GSDedicatedClient::deactivate() 94 94 { 95 if ( this->client_)95 if (this->client_) 96 96 { 97 97 this->client_->closeConnection(); 98 98 delete this->client_; 99 99 } 100 100 101 101 closeThread_ = true; 102 102 #ifdef ORXONOX_PLATFORM_UNIX … … 143 143 escapeChar = 2; 144 144 continue; 145 145 } 146 146 else if ( escapeChar == 2 ) 147 147 { -
code/trunk/src/orxonox/gamestates/GSServer.cc
r5929 r6021 30 30 31 31 #include "util/Debug.h" 32 #include "core/CommandLine .h"32 #include "core/CommandLineParser.h" 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" … … 55 55 GameMode::setHasServer(true); 56 56 57 this->server_ = new Server(CommandLine ::getValue("port"));57 this->server_ = new Server(CommandLineParser::getValue("port")); 58 58 COUT(0) << "Loading scene in server mode" << std::endl; 59 59
Note: See TracChangeset
for help on using the changeset viewer.