Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/sound5/src/libraries/core/CommandExecutor.h @ 10255

Last change on this file since 10255 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
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
29#ifndef _CommandExecutor_H__
30#define _CommandExecutor_H__
31
32#include "CorePrereqs.h"
33
34#include <map>
35#include <set>
36#include <string>
37
38#include "util/MultiType.h"
39#include "CommandEvaluation.h"
40
41// tolua_begin
42namespace orxonox
43{
44    class _CoreExport CommandExecutor
45    {
46// tolua_end
47        public:
48            static bool execute(const std::string& command, bool useTcl = true); // tolua_export
49            static MultiType getReturnValue();
50            static std::string getReturnValueString(); // tolua_export
51
52            static std::string complete(const std::string& command);
53            static std::string hint(const std::string& command);
54
55            static CommandEvaluation evaluate(const std::string& command);
56            static const CommandEvaluation& getLastEvaluation();
57
58            static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit = false);
59            static ConsoleCommand* getConsoleCommandShortcut(const std::string& name);
60            static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name);
61
62            /** @brief Returns the map that stores all console commands. @return The const_iterator */
63            static inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }
64            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
65            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }
66            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
67            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }
68
69            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
70            static inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }
71            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
72            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }
73            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
74            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
75
76            static void destroyExternalCommands();
77
78        private:
79            CommandExecutor() {}
80            CommandExecutor(const CommandExecutor& other);
81            ~CommandExecutor() {}
82
83            static CommandExecutor& getInstance();
84            static CommandEvaluation& getEvaluation();
85
86            static void parseIfNeeded(const std::string& command);
87            static void parse(const std::string& command, bool bInitialize = true);
88
89            static unsigned int argumentsFinished();
90            static unsigned int argumentsGiven();
91            static bool enoughArgumentsGiven(ConsoleCommand* command);
92            static const std::string& getArgument(unsigned int index);
93            static const std::string& getLastArgument();
94
95            static void createListOfPossibleIdentifiers(const std::string& fragment);
96            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
97            static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param);
98
99            static Identifier* getPossibleIdentifier(const std::string& name);
100            static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
101            static const std::string& getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
102
103            static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
104            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
105            static std::string getCommonBegin(const ArgumentCompletionList& list);
106
107            CommandEvaluation evaluation_;
108            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
109            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
110            std::set<ConsoleCommand*>              consoleCommandExternals_;
111    }; // tolua_export
112} // tolua_export
113
114#endif /* _CommandExecutor_H__ */
Note: See TracBrowser for help on using the repository browser.