[10345] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Reto Grieder |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @defgroup CmdArgs Commandline arguments |
---|
| 31 | @ingroup Config |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | @file |
---|
| 36 | @ingroup Config CmdArgs |
---|
| 37 | @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros. |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #ifndef _CommandLineIncludes_H__ |
---|
| 41 | #define _CommandLineIncludes_H__ |
---|
| 42 | |
---|
| 43 | #include "core/CorePrereqs.h" |
---|
| 44 | |
---|
| 45 | #include "CommandLineParser.h" |
---|
| 46 | #include "core/module/StaticallyInitializedInstance.h" |
---|
| 47 | |
---|
| 48 | #define SetCommandLineArgument(name, defaultValue) \ |
---|
| 49 | orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ |
---|
[10353] | 50 | = (new orxonox::SI_CLA(new orxonox::CommandLineArgument(#name, defaultValue)))->getArgument() |
---|
[10345] | 51 | #define SetCommandLineSwitch(name) \ |
---|
| 52 | SetCommandLineArgument(name, false) |
---|
| 53 | |
---|
| 54 | namespace orxonox |
---|
| 55 | { |
---|
| 56 | class _CoreExport StaticallyInitializedCommandLineArgument : public StaticallyInitializedInstance |
---|
| 57 | { |
---|
| 58 | public: |
---|
[10530] | 59 | StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) |
---|
[10535] | 60 | : StaticallyInitializedInstance(StaticInitialization::COMMAND_LINE_ARGUMENT) |
---|
[10530] | 61 | , argument_(argument) |
---|
| 62 | {} |
---|
[10520] | 63 | ~StaticallyInitializedCommandLineArgument() { delete argument_; } |
---|
[10345] | 64 | |
---|
[11071] | 65 | virtual void load() override |
---|
[10345] | 66 | { CommandLineParser::addArgument(this->argument_); } |
---|
| 67 | |
---|
[11071] | 68 | virtual void unload() override |
---|
[10404] | 69 | { CommandLineParser::removeArgument(this->argument_); } |
---|
| 70 | |
---|
[10345] | 71 | inline CommandLineArgument& getArgument() |
---|
| 72 | { return *this->argument_; } |
---|
| 73 | |
---|
| 74 | private: |
---|
| 75 | CommandLineArgument* argument_; |
---|
| 76 | }; |
---|
[10353] | 77 | |
---|
| 78 | typedef StaticallyInitializedCommandLineArgument SI_CLA; |
---|
[10345] | 79 | } |
---|
| 80 | |
---|
| 81 | #endif /* _CommandLineIncludes_H__ */ |
---|