Orxonox  0.0.5 Codename: Arcturus
ConsoleCommandManager.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 
34 #ifndef _ConsoleCommandManager_H__
35 #define _ConsoleCommandManager_H__
36 
37 #include "core/CorePrereqs.h"
38 
39 #include "util/Singleton.h"
40 
41 #include <map>
42 
43 namespace orxonox
44 {
48  class _CoreExport ConsoleCommandManager : public Singleton<ConsoleCommandManager>
49  {
51 
52  public:
53  void registerCommand(ConsoleCommand* command);
54  void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
55  void unregisterCommand(ConsoleCommand* command);
56 
58  inline const std::map<std::string, std::map<std::string, ConsoleCommand*>>& getCommands()
59  { return this->commandMap_; }
61  inline const std::map<std::string, std::map<std::string, ConsoleCommand*>>& getCommandsLC()
62  { return this->commandMapLC_; }
63 
65  inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
66  { return this->getCommand("", name, bPrintError); }
68  inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
69  { return this->getCommandLC("", name, bPrintError); }
70 
71  ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
72  ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
73 
74  private:
75  std::map<std::string, std::map<std::string, ConsoleCommand*>> commandMap_;
76  std::map<std::string, std::map<std::string, ConsoleCommand*>> commandMapLC_;
77 
79  };
80 }
81 
82 #endif /* _ConsoleCommandManager_H__ */
static ConsoleCommandManager * singletonPtr_s
Definition: ConsoleCommandManager.h:78
The ConsoleCommand class stores all information about a console command which can be executed by Comm...
Definition: ConsoleCommand.h:88
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
std::map< std::string, std::map< std::string, ConsoleCommand * > > commandMapLC_
Definition: ConsoleCommandManager.h:76
ConsoleCommand * getCommand(const std::string &name, bool bPrintError=false)
Returns a command (shortcut) with given name.
Definition: ConsoleCommandManager.h:65
ConsoleCommand * getCommandLC(const std::string &name, bool bPrintError=false)
Returns a command (shortcut) with given name in lowercase.
Definition: ConsoleCommandManager.h:68
A singleton that stores all existing ConsoleCommands.
Definition: ConsoleCommandManager.h:48
const std::map< std::string, std::map< std::string, ConsoleCommand * > > & getCommandsLC()
Returns the map with all groups and commands in lowercase.
Definition: ConsoleCommandManager.h:61
Base for singleton classes.
Definition: Singleton.h:114
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
#define _CoreExport
Definition: CorePrereqs.h:61
Definition of the Singleton template that is used as base class for classes that allow only one insta...
const std::map< std::string, std::map< std::string, ConsoleCommand * > > & getCommands()
Returns the map with all groups and commands.
Definition: ConsoleCommandManager.h:58
std::map< std::string, std::map< std::string, ConsoleCommand * > > commandMap_
Definition: ConsoleCommandManager.h:75