Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 4, 2011, 2:47:44 AM (13 years ago)
Author:
rgrieder
Message:

Merged unity_build branch back to trunk.

Features:

  • Implemented fully automatic build units to speed up compilation if requested
  • Added DOUT macro for quick debug output
  • Activated text colouring in the POSIX IOConsole
  • DeclareToluaInterface is not necessary anymore

Improvements:

  • Output levels now change appropriately when switch back and forth from dev mode
  • Log level for the file output is now also correct during startup
  • Removed some header file dependencies in core and tools to speed up compilation

no more file for command line options

  • Improved util::tribool by adapting some concepts from boost::tribool

Regressions:

  • It is not possible anymore to specify command line arguments in an extra file because we've got config values for that purpose.
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/CommandLineParser.h

    r7401 r8729  
    5151#define SetCommandLineArgument(name, defaultValue) \
    5252    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    53     = orxonox::CommandLineParser::addArgument(#name, defaultValue, false)
    54 #define SetCommandLineOnlyArgument(name, defaultValue) \
    55     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    56     = orxonox::CommandLineParser::addArgument(#name, defaultValue, true)
     53    = orxonox::CommandLineParser::addArgument(#name, defaultValue)
    5754#define SetCommandLineSwitch(name) \
    5855    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    59     = orxonox::CommandLineParser::addArgument(#name, false, false)
    60 #define SetCommandLineOnlySwitch(name) \
    61     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    62     = orxonox::CommandLineParser::addArgument(#name, false, true)
    63 
     56    = orxonox::CommandLineParser::addArgument(#name, false)
    6457
    6558namespace orxonox
     
    10699
    107100        //! Returns the actual value of the argument. Can be equal to default value.
    108         MultiType getValue() const { return value_; }
     101        const MultiType& getValue() const { return value_; }
    109102        //! Returns the given default value as type T.
    110         MultiType getDefaultValue() const { return defaultValue_; }
     103        const MultiType& getDefaultValue() const { return defaultValue_; }
    111104
    112105    private:
    113106        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
    114         CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
     107        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
    115108            : bHasDefaultValue_(true)
    116109            , name_(name)
    117110            , value_(defaultValue)
    118111            , defaultValue_(defaultValue)
    119             , bCommandLineOnly_(bCommandLineOnly)
    120112        { }
    121113
     
    125117
    126118        //! Parses the value string of a command line argument.
    127         void parse(const std::string& value, bool bParsingFile);
     119        void parse(const std::string& value);
    128120
    129121        //! Tells whether the value has been changed by the command line.
     
    137129        MultiType   value_;            //!< The actual value
    138130        MultiType   defaultValue_;     //!< Default value. Should not be changed.
    139         bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
    140131    };
    141132
     
    155146
    156147        //! Parse redirection to internal member method.
    157         static void parseCommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }
    158         static void parseFile() { _getInstance()._parseFile(); }
     148        static void parse(const std::string& cmdLine)
     149        { _getInstance()._parse(cmdLine); }
    159150
    160151        static std::string getUsageInformation();
     
    165156        static void getValue(const std::string& name, T* value)
    166157        { *value = (T)(getArgument(name)->getValue()); }
    167         static MultiType getValue(const std::string& name)
     158        static const MultiType& getValue(const std::string& name)
    168159        { return getArgument(name)->getValue(); }
    169160        template <class T>
    170         static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
     161        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
    171162
    172163        static bool existsArgument(const std::string& name)
     
    189180        static CommandLineParser& _getInstance();
    190181
    191         void _parseCommandLine(const std::string& cmdLine);
    192         void _parseFile();
    193         void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
    194         void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
    195         void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
     182        void _parse(const std::string& cmdLine);
     183        void checkFullArgument(const std::string& name, const std::string& value);
     184        void checkShortcut(const std::string& shortcut, const std::string& value);
    196185
    197186        /**
     
    222211    @param defaultValue
    223212        Default value that is used when argument was not given.
    224     @param bCommandLineOnly
    225         Parsing a file or the command line itself
    226213    */
    227214    template <class T>
    228     CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
     215    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)
    229216    {
    230217        OrxAssert(!_getInstance().existsArgument(name),
     
    234221            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
    235222
    236         return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
     223        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
    237224    }
    238225}
Note: See TracChangeset for help on using the changeset viewer.