Index: code/branches/gui/src/core/CommandLine.cc
===================================================================
--- code/branches/gui/src/core/CommandLine.cc	(revision 1663)
+++ code/branches/gui/src/core/CommandLine.cc	(revision 1663)
@@ -0,0 +1,134 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandLine.h"
+
+namespace orxonox
+{
+    CommandLine::~CommandLine()
+    {
+        for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+            it != cmdLineArgs_.end(); ++it)
+        {
+            delete it->second;
+        }
+    }
+    
+    CommandLine& CommandLine::_getInstance()
+    {
+        static CommandLine instance;
+        return instance;
+    }
+
+    void CommandLine::_parse(int argc, char** argv)
+    {
+        if (bFirstTimeParse_)
+        {
+            // first shove all the shortcuts in a map
+            for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+                it != cmdLineArgs_.end(); ++it)
+            {
+                OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+                    "Cannot have two command line shortcut with the same name.");
+                if (it->second->getShortcut() != "")
+                    cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+            }
+            bFirstTimeParse_ = false;
+        }
+
+        std::string name;
+        std::string shortcut;
+        std::string val;
+        for (int i = 1; i < argc; ++i)
+        {
+            if (argv[i][0] == '-')
+            {
+                if (argv[i][1] <= 57 && argv[i][1] >= 48)
+                {
+                    // negative number as a value
+                    val += std::string(argv[i]) + " ";
+                }
+                else
+                {
+                    // save old data first
+                    if (name != "")
+                    {
+                        checkFullArgument(name, val);
+                        name = "";
+                        assert(shortcut == "");
+                    }
+                    else if (shortcut != "")
+                    {
+                        checkShortcut(shortcut, val);
+                        shortcut = "";
+                        assert(name == "");
+                    }
+
+                    if (argv[i][1] == '-')
+                    {
+                        // full name argument
+                        name = argv[i] + 2;
+                    }
+                    else
+                    {
+                        // short cut
+                        shortcut = argv[i] + 1;
+                    }
+                    val = "";
+                }
+            }
+            else // value
+            {
+                if (name == "" && shortcut == "")
+                {
+                    ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
+                }
+
+                val += argv[i];
+            }
+        }
+    }
+
+    void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
+        if (it == cmdLineArgs_.end())
+            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
+        if (it == cmdLineArgsShortcut_.end())
+            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
+
+        it->second->parse(value);
+    }
+}
Index: code/branches/gui/src/core/CommandLine.h
===================================================================
--- code/branches/gui/src/core/CommandLine.h	(revision 1663)
+++ code/branches/gui/src/core/CommandLine.h	(revision 1663)
@@ -0,0 +1,176 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandLine_H__
+#define _CommandLine_H__
+
+#include "CorePrereqs.h"
+#include <map>
+#include "util/Convert.h"
+#include "Debug.h"
+#include "Exception.h"
+
+
+#define SetCommandLineArgument(name, defaultValue) \
+    BaseCommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLine::addCommandLineArgument(#name, defaultValue)
+
+namespace orxonox
+{
+    class _CoreExport BaseCommandLineArgument
+    {
+        friend class CommandLine;
+
+    public:
+        bool hasDefaultValue() const { return bHasDefaultValue_; }
+        const std::string& getName() const { return name_; }
+        const std::string& getShortcut() const { return shortcut_; }
+        BaseCommandLineArgument& setShortcut(const std::string& shortcut)
+        { this->shortcut_ = shortcut; return *this; }
+
+    protected:
+        BaseCommandLineArgument(const std::string& name)
+            : name_(name)
+            , bHasDefaultValue_(true)
+        { }
+
+        BaseCommandLineArgument(const BaseCommandLineArgument& instance);
+        virtual ~BaseCommandLineArgument() { }
+
+        virtual void parse(const std::string& value) = 0;
+
+        bool bHasDefaultValue_;
+
+    private:
+        std::string name_;
+        std::string shortcut_;
+    };
+
+
+    template <class T>
+    class CommandLineArgument : public BaseCommandLineArgument
+    {
+        friend class CommandLine;
+
+    public:
+        T getValue() const { return value_; }
+        T getDefaultValue() const { return defaultValue_; }
+
+    private:
+        CommandLineArgument(const std::string& name, const T& defaultValue)
+            : BaseCommandLineArgument(name)
+            , value_(defaultValue)
+            , defaultValue_(defaultValue)
+        { }
+
+        virtual void parse(const std::string& value);
+
+        T value_;
+        T defaultValue_;
+    };
+
+    template <class T>
+    void CommandLineArgument<T>::parse(const std::string& value)
+    {
+        if (convertValue(&this->value_, value))
+        {
+            this->bHasDefaultValue_ = false;
+        }
+        else
+        {
+            ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+        }
+    }
+
+
+    class _CoreExport CommandLine
+    {
+    public:
+
+        static void parse(int argc, char** argv) { _getInstance()._parse(argc, argv); }
+
+        template <class T>
+        static const CommandLineArgument<T>* getCommandLineArgument(const std::string& name);
+        template <class T>
+        static BaseCommandLineArgument& addCommandLineArgument(const std::string& name,
+            const T& defaultValue);
+
+    private:
+        CommandLine() : bFirstTimeParse_(true) { }
+        CommandLine(const CommandLine& instance);
+        ~CommandLine();
+
+        static CommandLine& _getInstance();
+
+        void _parse(int argc, char** argv);
+        void checkFullArgument(const std::string& name, const std::string& value);
+        void checkShortcut(const std::string& shortcut, const std::string& value);
+
+        bool bFirstTimeParse_;
+
+        std::map<std::string, BaseCommandLineArgument*> cmdLineArgs_;
+        std::map<std::string, BaseCommandLineArgument*> cmdLineArgsShortcut_;
+    };
+
+
+    template <class T>
+    const CommandLineArgument<T>* CommandLine::getCommandLineArgument(const std::string& name)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        if (it == _getInstance().cmdLineArgs_.end())
+        {
+            ThrowException(Argument, "Could find command line argument '" + name + "'.");
+        }
+        else
+        {
+            CommandLineArgument<T>* arg = dynamic_cast<CommandLineArgument<T>* >(it->second);
+            if (arg == 0)
+            {
+                ThrowException(Argument, "Could not convert command line argument value to requested type. " \
+                    "You should use exactly the same type as predefined.");
+            }
+            else
+            {
+                return arg;
+            }
+        }
+    }
+
+    template <class T>
+    BaseCommandLineArgument& CommandLine::addCommandLineArgument(const std::string& name,
+                                             const T& defaultValue)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        OrxAssert(it == _getInstance().cmdLineArgs_.end(),
+            "Cannot add a command line argument with name '" + name + "' twice.");
+
+        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument<T>(name, defaultValue));
+    }
+}
+
+#endif /* _CommandLine_H__ */
Index: code/branches/gui/src/core/CorePrereqs.h
===================================================================
--- code/branches/gui/src/core/CorePrereqs.h	(revision 1662)
+++ code/branches/gui/src/core/CorePrereqs.h	(revision 1663)
@@ -102,4 +102,8 @@
   class CommandEvaluation;
   class CommandExecutor;
+  class CommandLine;
+  class BaseCommandLineArgument;
+  template <class T>
+  class CommandLineArgument;
   class ConfigFile;
   class ConfigFileEntry;
Index: code/branches/gui/src/core/Exception.h
===================================================================
--- code/branches/gui/src/core/Exception.h	(revision 1662)
+++ code/branches/gui/src/core/Exception.h	(revision 1663)
@@ -59,4 +59,5 @@
             General,
             FileNotFound,
+            Argument,
             PluginsNotFound,
             InitialisationFailed,
@@ -119,4 +120,5 @@
             RETURN_EXCEPTION_CODE(General)
             RETURN_EXCEPTION_CODE(FileNotFound);
+            RETURN_EXCEPTION_CODE(Argument);
             RETURN_EXCEPTION_CODE(PluginsNotFound);
             RETURN_EXCEPTION_CODE(InitialisationFailed);
@@ -132,4 +134,5 @@
     CREATE_ORXONOX_EXCEPTION(General);
     CREATE_ORXONOX_EXCEPTION(FileNotFound);
+    CREATE_ORXONOX_EXCEPTION(Argument);
     CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
     CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
@@ -142,7 +145,7 @@
     // define an assert macro that can display a message
 #ifndef NDEBUG
-#define OrxAssert(condition, errorMessage) \
-    condition ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \
-    assert(condition)
+#define OrxAssert(assertion, errorMessage) \
+    assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \
+    assert(assertion)
 #else
 #define OrxAssert(condition, errorMessage)  ((void)0)
