Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6021 for code/trunk


Ignore:
Timestamp:
Nov 4, 2009, 12:28:59 PM (15 years ago)
Author:
rgrieder
Message:

Renamed CommandLine to CommandLineParse to avoid confusions with the class name.

Location:
code/trunk/src
Files:
2 deleted
12 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/CMakeLists.txt

    r5929 r6021  
    4040  CommandEvaluation.cc
    4141  CommandExecutor.cc
    42   CommandLine.cc
     42  CommandLineParser.cc
    4343  ConsoleCommand.cc
    4444  ConsoleCommandCompilation.cc
  • code/trunk/src/libraries/core/CommandLineParser.cc

    r6014 r6021  
    2727 */
    2828
    29 #include "CommandLine.h"
     29#include "CommandLineParser.h"
    3030
    3131#include <algorithm>
     
    8888        Destructor destroys all CommandLineArguments with it.
    8989    */
    90     CommandLine::~CommandLine()
    91     {
    92         CommandLine::destroyAllArguments();
     90    CommandLineParser::~CommandLineParser()
     91    {
     92        CommandLineParser::destroyAllArguments();
    9393    }
    9494
     
    9797        Returns a unique instance (Meyers Singleton).
    9898    */
    99     CommandLine& CommandLine::_getInstance()
    100     {
    101         static CommandLine instance;
     99    CommandLineParser& CommandLineParser::_getInstance()
     100    {
     101        static CommandLineParser instance;
    102102        return instance;
    103103    }
     
    108108        of main. Do not use before that.
    109109    */
    110     void CommandLine::destroyAllArguments()
     110    void CommandLineParser::destroyAllArguments()
    111111    {
    112112        for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
     
    127127        Vector of space separated strings.
    128128    */
    129     void CommandLine::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
     129    void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
    130130    {
    131131        try
     
    232232        {
    233233            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;
    235235            throw GeneralException("");
    236236        }
     
    245245        String containing the value
    246246    */
    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)
    248248    {
    249249        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
     
    262262        String containing the value
    263263    */
    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)
    265265    {
    266266        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
     
    271271    }
    272272
    273     std::string CommandLine::getUsageInformation()
    274     {
    275         CommandLine& inst = _getInstance();
     273    std::string CommandLineParser::getUsageInformation()
     274    {
     275        CommandLineParser& inst = _getInstance();
    276276        std::ostringstream infoStr;
    277277
     
    315315        You shold of course not call this method before the command line has been parsed.
    316316    */
    317     const CommandLineArgument* CommandLine::getArgument(const std::string& name)
     317    const CommandLineArgument* CommandLineParser::getArgument(const std::string& name)
    318318    {
    319319        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
     
    332332        Parses only the command line for CommandLineArguments.
    333333    */
    334     void CommandLine::_parseCommandLine(const std::string& cmdLine)
     334    void CommandLineParser::_parseCommandLine(const std::string& cmdLine)
    335335    {
    336336        std::vector<std::string> args;
     
    345345        Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
    346346    */
    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();
    350350
    351351        // look for additional arguments in given file or start.ini as default
  • code/trunk/src/libraries/core/CommandLineParser.h

    r6014 r6021  
    3838#define SetCommandLineArgument(name, defaultValue) \
    3939    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    40     = orxonox::CommandLine::addArgument(#name, defaultValue, false)
     40    = orxonox::CommandLineParser::addArgument(#name, defaultValue, false)
    4141#define SetCommandLineOnlyArgument(name, defaultValue) \
    4242    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    43     = orxonox::CommandLine::addArgument(#name, defaultValue, true)
     43    = orxonox::CommandLineParser::addArgument(#name, defaultValue, true)
    4444#define SetCommandLineSwitch(name) \
    4545    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    46     = orxonox::CommandLine::addArgument(#name, false, false)
     46    = orxonox::CommandLineParser::addArgument(#name, false, false)
    4747#define SetCommandLineOnlySwitch(name) \
    4848    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    49     = orxonox::CommandLine::addArgument(#name, false, true)
     49    = orxonox::CommandLineParser::addArgument(#name, false, true)
    5050
    5151
     
    6767
    6868        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.
    7070    */
    7171    class _CoreExport CommandLineArgument
    7272    {
    73         friend class CommandLine;
     73        friend class CommandLineParser;
    7474
    7575    public:
     
    137137        CommandLineArgument
    138138    */
    139     class _CoreExport CommandLine
     139    class _CoreExport CommandLineParser
    140140    {
    141141    public:
     
    167167    private:
    168168        //! Constructor initialises bFirstTimeParse_ with true.
    169         CommandLine() : bFirstTimeParse_(true) { }
     169        CommandLineParser() : bFirstTimeParse_(true) { }
    170170        //! 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();
    175175
    176176        void _parseCommandLine(const std::string& cmdLine);
     
    194194
    195195    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)
    197197    {
    198198        *value = getArgument(name)->getValue().getString();
     
    209209    */
    210210    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)
    212212    {
    213213        OrxAssert(!_getInstance().existsArgument(name),
  • code/trunk/src/libraries/core/Core.cc

    r5929 r6021  
    5454#include "PathConfig.h"
    5555#include "CommandExecutor.h"
    56 #include "CommandLine.h"
     56#include "CommandLineParser.h"
    5757#include "ConfigFileManager.h"
    5858#include "ConfigValueIncludes.h"
     
    216216
    217217        // Parse command line arguments AFTER the modules have been loaded (static code!)
    218         CommandLine::parseCommandLine(cmdLine);
     218        CommandLineParser::parseCommandLine(cmdLine);
    219219
    220220        // Set configurable paths like log, config and media
     
    230230
    231231        // Parse additional options file now that we know its path
    232         CommandLine::parseFile();
     232        CommandLineParser::parseFile();
    233233
    234234#ifdef ORXONOX_PLATFORM_WINDOWS
     
    236236        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    237237        // the timer though).
    238         int limitToCPU = CommandLine::getValue("limitToCPU");
     238        int limitToCPU = CommandLineParser::getValue("limitToCPU");
    239239        if (limitToCPU > 0)
    240240            setThreadAffinity(static_cast<unsigned int>(limitToCPU));
     
    244244        this->configFileManager_.reset(new ConfigFileManager());
    245245        this->configFileManager_->setFilename(ConfigFileType::Settings,
    246             CommandLine::getValue("settingsFile").getString());
     246            CommandLineParser::getValue("settingsFile").getString());
    247247
    248248        // Required as well for the config values
  • code/trunk/src/libraries/core/CorePrereqs.h

    r5929 r6021  
    116116    class ClassTreeMaskObjectIterator;
    117117    class CommandEvaluation;
    118     class CommandLine;
     118    class CommandLineParser;
    119119    class CommandLineArgument;
    120120    class ConfigFile;
  • code/trunk/src/libraries/core/Game.cc

    r5929 r6021  
    4444#include "util/Sleep.h"
    4545#include "util/SubString.h"
    46 #include "CommandLine.h"
     46#include "CommandLineParser.h"
    4747#include "ConsoleCommand.h"
    4848#include "Core.h"
  • code/trunk/src/libraries/core/PathConfig.cc

    r5929 r6021  
    5454#include "util/Debug.h"
    5555#include "util/Exception.h"
    56 #include "CommandLine.h"
     56#include "CommandLineParser.h"
    5757
    5858// Boost 1.36 has some issues with deprecated functions that have been omitted
     
    186186
    187187            // 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();
    190190            else
    191191                externalDataPath_ = specialConfig::externalDataDevDirectory;
     
    224224
    225225        // 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());
    229229            configPath_ = configPath_ / directory;
    230230            logPath_    = logPath_    / directory;
  • code/trunk/src/libraries/core/input/InputManager.cc

    r5929 r6021  
    4848#include "core/ConfigValueIncludes.h"
    4949#include "core/ConsoleCommand.h"
    50 #include "core/CommandLine.h"
     50#include "core/CommandLineParser.h"
    5151#include "core/Functor.h"
    5252#include "core/GraphicsManager.h"
     
    170170        if (mouseMode_ == MouseMode::Exclusive || GraphicsManager::getInstance().isFullScreen())
    171171        {
    172             if (CommandLine::getValue("keyboard_no_grab").getBool())
     172            if (CommandLineParser::getValue("keyboard_no_grab").getBool())
    173173                paramList.insert(std::make_pair("x11_keyboard_grab", "false"));
    174174            else
  • code/trunk/src/orxonox/LevelManager.cc

    r5929 r6021  
    3232#include <OgreResourceGroupManager.h>
    3333
    34 #include "core/CommandLine.h"
     34#include "core/CommandLineParser.h"
    3535#include "core/ConfigValueIncludes.h"
    3636#include "core/CoreIncludes.h"
     
    5353
    5454        // check override
    55         if (!CommandLine::getArgument("level")->hasDefaultValue())
     55        if (!CommandLineParser::getArgument("level")->hasDefaultValue())
    5656        {
    57             ModifyConfigValue(defaultLevelName_, tset, CommandLine::getValue("level").getString());
     57            ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").getString());
    5858        }
    5959    }
  • code/trunk/src/orxonox/Main.cc

    r5929 r6021  
    3636#include "OrxonoxPrereqs.h"
    3737
    38 #include "core/CommandLine.h"
     38#include "core/CommandLineParser.h"
    3939#include "core/Game.h"
    4040#include "core/LuaState.h"
     
    7676
    7777        // 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())
    7979            Game::getInstance().requestStates("graphics, standalone, level");
    80         else if (CommandLine::getValue("server").getBool())
     80        else if (CommandLineParser::getValue("server").getBool())
    8181            Game::getInstance().requestStates("graphics, server, level");
    82         else if (CommandLine::getValue("client").getBool())
     82        else if (CommandLineParser::getValue("client").getBool())
    8383            Game::getInstance().requestStates("graphics, client, level");
    84         else if (CommandLine::getValue("dedicated").getBool())
     84        else if (CommandLineParser::getValue("dedicated").getBool())
    8585            Game::getInstance().requestStates("dedicated, level");
    86         else if (CommandLine::getValue("dedicatedClient").getBool())
     86        else if (CommandLineParser::getValue("dedicatedClient").getBool())
    8787            Game::getInstance().requestStates("dedicatedClient, level");
    88         else if (CommandLine::getValue("console").getBool())
     88        else if (CommandLineParser::getValue("console").getBool())
    8989            Game::getInstance().requestStates("ioConsole");
    9090        else
  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r5929 r6021  
    3131#include "util/Clock.h"
    3232#include "util/Exception.h"
    33 #include "core/CommandLine.h"
     33#include "core/CommandLineParser.h"
    3434#include "core/Game.h"
    3535#include "core/GameMode.h"
     
    5656        GameMode::setIsClient(true);
    5757
    58         this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     58        this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLineParser::getValue("port"));
    5959
    6060        if(!client_->establishConnection())
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r5929 r6021  
    3636#include "util/Debug.h"
    3737#include "util/Sleep.h"
    38 #include "core/CommandLine.h"
     38#include "core/CommandLineParse.h"
    3939#include "core/CommandExecutor.h"
    4040#include "core/Game.h"
     
    8181#endif
    8282
    83         this->server_ = new Server(CommandLine::getValue("port"));
     83        this->server_ = new Server(CommandLineParser::getValue("port"));
    8484        COUT(0) << "Loading scene in server mode" << std::endl;
    8585
     
    9191        this->server_->close();
    9292        delete this->server_;
    93        
     93
    9494        closeThread_ = true;
    9595#ifdef ORXONOX_PLATFORM_UNIX
     
    138138                        escapeChar = 2;
    139139                        continue;
    140                     }
     140}
    141141                    else if ( escapeChar == 2 )
    142142                    {
  • code/trunk/src/orxonox/gamestates/GSDedicatedClient.cc

    r5929 r6021  
    3737#include "util/Exception.h"
    3838#include "util/Sleep.h"
    39 #include "core/CommandLine.h"
     39#include "core/CommandLineParser.h"
    4040#include "core/CommandExecutor.h"
    4141#include "core/Game.h"
     
    8080#endif
    8181
    82         this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     82        this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLine::getValue("port"));
    8383        COUT(0) << "Loading scene in client mode" << std::endl;
    8484
     
    9393    void GSDedicatedClient::deactivate()
    9494    {
    95         if( this->client_ )
     95        if (this->client_)
    9696        {
    9797            this->client_->closeConnection();
    9898            delete this->client_;
    9999        }
    100        
     100
    101101        closeThread_ = true;
    102102#ifdef ORXONOX_PLATFORM_UNIX
     
    143143                        escapeChar = 2;
    144144                        continue;
    145                     }
     145}
    146146                    else if ( escapeChar == 2 )
    147147                    {
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r5929 r6021  
    3030
    3131#include "util/Debug.h"
    32 #include "core/CommandLine.h"
     32#include "core/CommandLineParser.h"
    3333#include "core/Game.h"
    3434#include "core/GameMode.h"
     
    5555        GameMode::setHasServer(true);
    5656
    57         this->server_ = new Server(CommandLine::getValue("port"));
     57        this->server_ = new Server(CommandLineParser::getValue("port"));
    5858        COUT(0) << "Loading scene in server mode" << std::endl;
    5959
Note: See TracChangeset for help on using the changeset viewer.