Orxonox  0.0.5 Codename: Arcturus
ConsoleCommandIncludes.h
Go to the documentation of this file.
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  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
217 #ifndef _ConsoleCommandIncludes_H__
218 #define _ConsoleCommandIncludes_H__
219 
220 #include "core/CorePrereqs.h"
221 
222 #include "ConsoleCommand.h"
223 #include "ConsoleCommandManager.h"
224 #include "util/VA_NARGS.h"
226 
227 
238 #define SetConsoleCommand(...) \
239  BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
240 
245 #define SetConsoleCommand2(name, functionpointer) \
246  SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
247 
253 #define SetConsoleCommand3(group, name, functionpointer) \
254  SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
255 
262 #define SetConsoleCommand4(group, name, functionpointer, object) \
263  SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
264 
266 #define SetConsoleCommandGeneric(group, name, functor) \
267  static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
268  = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))))->getCommand()
269 
270 
283 #define DeclareConsoleCommand(...) \
284  BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
285 
290 #define DeclareConsoleCommand2(name, functionpointer) \
291  DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
292 
298 #define DeclareConsoleCommand3(group, name, functionpointer) \
299  DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
300 
302 #define DeclareConsoleCommandGeneric(group, name, functor) \
303  static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
304  = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)))->getCommand()
305 
306 
307 namespace orxonox
308 {
310  {
311  public:
313  : StaticallyInitializedInstance(StaticInitialization::CONSOLE_COMMAND)
314  , command_(command)
315  {}
317 
318  virtual void load() override;
319  virtual void unload() override;
320 
322  { return *this->command_; }
323 
324  private:
326  };
327 
329 
338  { return ConsoleCommandManager::getInstance().getCommand(name, true); }
347  { return ConsoleCommandManager::getInstance().getCommand(group, name, true); }
348 }
349 
350 #endif /* _ConsoleCommandIncludes_H__ */
~StaticallyInitializedConsoleCommand()
Definition: ConsoleCommandIncludes.h:316
The ConsoleCommand class stores all information about a console command which can be executed by Comm...
Definition: ConsoleCommand.h:88
Declaration of the ORXONOX_VA_NARGS macro which returns the number of arguments passed to a variadic ...
ConsoleCommand * command_
Definition: ConsoleCommandIncludes.h:325
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
ConsoleCommand * getCommand(const std::string &name, bool bPrintError=false)
Returns a command (shortcut) with given name.
Definition: ConsoleCommandManager.h:65
Definition: ConsoleCommandIncludes.h:309
ConsoleCommand & getCommand()
Definition: ConsoleCommandIncludes.h:321
StaticallyInitializedConsoleCommand(ConsoleCommand *command)
Definition: ConsoleCommandIncludes.h:312
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI() command(const std::string &fragment)
Returns a list of commands and groups and also supports auto-completion of the arguments of these com...
Definition: ArgumentCompletionFunctions.cc:178
Definition: StaticallyInitializedInstance.h:36
#define _CoreExport
Definition: CorePrereqs.h:61
Declaration of the orxonox::ConsoleCommand class.
static constexpr Type CONSOLE_COMMAND
Definition: CorePrereqs.h:97
ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string &name)
Returns a manipulator for a command with the given name.
Definition: ConsoleCommandIncludes.h:337
static ConsoleCommandManager & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
StaticallyInitializedConsoleCommand SI_CC
Definition: ConsoleCommandIncludes.h:328
Helper class that is used to manipulate console commands.
Definition: ConsoleCommand.h:124