Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.h @ 7277

Last change on this file since 7277 was 7277, checked in by landauf, 14 years ago

added new console command "alias" that can bind commands (including arguments) to a new name

  • Property svn:eol-style set to native
File size: 2.8 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 "core/CorePrereqs.h"
33
34#include <map>
35#include <list>
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 int execute(const std::string& command, bool useTcl = true); // tolua_export
49
50            static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true);
51            static std::string query(const std::string& command, int* error = 0, bool useTcl = true); // tolua_export
52
53            static CommandEvaluation evaluate(const std::string& command);
54
55            static const int Success = 0;
56            static const int Error = 1;
57            static const int Incomplete = 2;
58            static const int Deactivated = 3;
59            static const int Denied = 4;
60
61            static MultiType unhide(const std::string& command);
62            static void alias(const std::string& alias, const std::string& command);
63            static void _autocomplete(const std::string& group, const std::string& name) {}
64
65        private:
66            CommandExecutor() {}
67            CommandExecutor(const CommandExecutor& other);
68            ~CommandExecutor() {}
69
70            static CommandExecutor& getInstance();
71
72            bool getCached(const std::string& command, CommandEvaluation& evaluation);
73            void cache(const std::string& command, const CommandEvaluation& evaluation);
74
75            struct CacheEntry
76            {
77                CommandEvaluation evaluation_;
78                std::list<std::string>::iterator iterator_;
79            };
80
81            std::map<std::string, CacheEntry> cache_;
82            std::list<std::string> cachelist_;
83    }; // tolua_export
84} // tolua_export
85
86#endif /* _CommandExecutor_H__ */
Note: See TracBrowser for help on using the repository browser.