Changeset 10345 for code/branches/core7/src/libraries
- Timestamp:
- Apr 5, 2015, 5:32:40 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10343 r10345 60 60 #include "util/SignalHandler.h" 61 61 #include "PathConfig.h" 62 #include "commandline/CommandLine Parser.h"62 #include "commandline/CommandLineIncludes.h" 63 63 #include "config/ConfigFileManager.h" 64 64 #include "config/ConfigValueIncludes.h" … … 140 140 } 141 141 142 // TODO: initialize CommandLineParser here 142 143 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 143 144 -
code/branches/core7/src/libraries/core/PathConfig.cc
r10343 r10345 53 53 #include "util/Output.h" 54 54 #include "util/Exception.h" 55 #include "commandline/CommandLine Parser.h"55 #include "commandline/CommandLineIncludes.h" 56 56 57 57 // Differentiate Boost Filesystem v2 and v3 -
code/branches/core7/src/libraries/core/commandline/CommandLineParser.cc
r10343 r10345 338 338 } 339 339 } 340 341 /** 342 @brief 343 Adds a new CommandLineArgument to the internal map. 344 Note that only such arguments are actually valid. 345 */ 346 void CommandLineParser::addArgument(CommandLineArgument* argument) 347 { 348 OrxAssert(!_getInstance().existsArgument(argument->getName()), 349 "Cannot add a command line argument with name '" + argument->getName() + "' twice."); 350 OrxAssert(!argument->getDefaultValue().isType<bool>() || argument->getDefaultValue().get<bool>() != true, 351 "Boolean command line arguments with positive default values are not supported." << endl 352 << "Please use SetCommandLineSwitch and adjust your argument: " << argument->getName()); 353 354 _getInstance().cmdLineArgs_[argument->getName()] = argument; 355 } 340 356 } -
code/branches/core7/src/libraries/core/commandline/CommandLineParser.h
r10343 r10345 49 49 #include "util/MultiType.h" 50 50 51 #define SetCommandLineArgument(name, defaultValue) \52 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \53 = orxonox::CommandLineParser::addArgument(#name, defaultValue)54 #define SetCommandLineSwitch(name) \55 orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \56 = orxonox::CommandLineParser::addArgument(#name, false)57 58 51 namespace orxonox 59 52 { … … 80 73 81 74 public: 75 //! Constructor initialises both value_ and defaultValue_ with defaultValue. 76 CommandLineArgument(const std::string& name, const MultiType& defaultValue) 77 : bHasDefaultValue_(true) 78 , name_(name) 79 , value_(defaultValue) 80 , defaultValue_(defaultValue) 81 { } 82 ~CommandLineArgument() { } 83 82 84 //! Tells whether the value has been changed by the command line. 83 85 bool hasDefaultValue() const { return bHasDefaultValue_; } … … 104 106 105 107 private: 106 //! Constructor initialises both value_ and defaultValue_ with defaultValue.107 CommandLineArgument(const std::string& name, const MultiType& defaultValue)108 : bHasDefaultValue_(true)109 , name_(name)110 , value_(defaultValue)111 , defaultValue_(defaultValue)112 { }113 114 108 //! Undefined copy constructor 115 109 CommandLineArgument(const CommandLineArgument& instance); 116 ~CommandLineArgument() { }117 110 118 111 //! Parses the value string of a command line argument. … … 158 151 static const MultiType& getValue(const std::string& name) 159 152 { return getArgument(name)->getValue(); } 160 template <class T> 161 static CommandLineArgument& addArgument(const std::string& name, T defaultValue); 153 static void addArgument(CommandLineArgument* argument); 162 154 163 155 static bool existsArgument(const std::string& name) … … 202 194 *value = getArgument(name)->getValue().get<std::string>(); 203 195 } 204 205 /**206 @brief207 Adds a new CommandLineArgument to the internal map.208 Note that only such arguments are actually valid.209 @param name210 Name of the argument. Shortcut can be added later.211 @param defaultValue212 Default value that is used when argument was not given.213 */214 template <class T>215 CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)216 {217 OrxAssert(!_getInstance().existsArgument(name),218 "Cannot add a command line argument with name '" + name + "' twice.");219 OrxAssert(!MultiType(defaultValue).isType<bool>() || MultiType(defaultValue).get<bool>() != true,220 "Boolean command line arguments with positive default values are not supported." << endl221 << "Please use SetCommandLineSwitch and adjust your argument: " << name);222 223 return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));224 }225 196 } 226 197 -
code/branches/core7/src/libraries/core/input/InputManager.cc
r10343 r10345 48 48 #include "core/GraphicsManager.h" 49 49 #include "core/config/ConfigValueIncludes.h" 50 #include "core/commandline/CommandLine Parser.h"50 #include "core/commandline/CommandLineIncludes.h" 51 51 #include "core/command/ConsoleCommand.h" 52 52 #include "core/command/Functor.h"
Note: See TracChangeset
for help on using the changeset viewer.