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 | @brief For a reference of all commandline arguments see @ref cmdargspage |
---|
33 | */ |
---|
34 | |
---|
35 | /** |
---|
36 | @file |
---|
37 | @ingroup Config CmdArgs |
---|
38 | @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros. |
---|
39 | */ |
---|
40 | |
---|
41 | #ifndef _CommandLineIncludes_H__ |
---|
42 | #define _CommandLineIncludes_H__ |
---|
43 | |
---|
44 | #include "core/CorePrereqs.h" |
---|
45 | |
---|
46 | #include "CommandLineParser.h" |
---|
47 | #include "core/module/StaticallyInitializedInstance.h" |
---|
48 | |
---|
49 | #define SetCommandLineArgument(name, defaultValue) \ |
---|
50 | orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \ |
---|
51 | = (new orxonox::SI_CLA(new orxonox::CommandLineArgument(#name, defaultValue)))->getArgument() |
---|
52 | #define SetCommandLineSwitch(name) \ |
---|
53 | SetCommandLineArgument(name, false) |
---|
54 | |
---|
55 | namespace orxonox |
---|
56 | { |
---|
57 | class _CoreExport StaticallyInitializedCommandLineArgument : public StaticallyInitializedInstance |
---|
58 | { |
---|
59 | public: |
---|
60 | StaticallyInitializedCommandLineArgument(CommandLineArgument* argument) |
---|
61 | : StaticallyInitializedInstance(StaticInitialization::COMMAND_LINE_ARGUMENT) |
---|
62 | , argument_(argument) |
---|
63 | {} |
---|
64 | ~StaticallyInitializedCommandLineArgument() { delete argument_; } |
---|
65 | |
---|
66 | virtual void load() |
---|
67 | { CommandLineParser::addArgument(this->argument_); } |
---|
68 | |
---|
69 | virtual void unload() |
---|
70 | { CommandLineParser::removeArgument(this->argument_); } |
---|
71 | |
---|
72 | inline CommandLineArgument& getArgument() |
---|
73 | { return *this->argument_; } |
---|
74 | |
---|
75 | private: |
---|
76 | CommandLineArgument* argument_; |
---|
77 | }; |
---|
78 | |
---|
79 | typedef StaticallyInitializedCommandLineArgument SI_CLA; |
---|
80 | } |
---|
81 | |
---|
82 | #endif /* _CommandLineIncludes_H__ */ |
---|