[1505] | 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 | |
---|
[7203] | 32 | #include "core/CorePrereqs.h" |
---|
[1505] | 33 | |
---|
[7229] | 34 | #include <map> |
---|
| 35 | #include <list> |
---|
[3196] | 36 | #include <string> |
---|
[1505] | 37 | |
---|
[3196] | 38 | #include "util/MultiType.h" |
---|
[1505] | 39 | #include "CommandEvaluation.h" |
---|
| 40 | |
---|
[2710] | 41 | // tolua_begin |
---|
| 42 | namespace orxonox |
---|
| 43 | { |
---|
[1505] | 44 | class _CoreExport CommandExecutor |
---|
| 45 | { |
---|
[2710] | 46 | // tolua_end |
---|
[1505] | 47 | public: |
---|
[7228] | 48 | static int execute(const std::string& command, bool useTcl = true); // tolua_export |
---|
[3035] | 49 | |
---|
[7228] | 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 |
---|
[7189] | 52 | |
---|
[1505] | 53 | static CommandEvaluation evaluate(const std::string& command); |
---|
| 54 | |
---|
[7228] | 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 | |
---|
[7234] | 61 | static MultiType unhide(const std::string& command); |
---|
[7228] | 62 | static void _autocomplete(const std::string& group, const std::string& name) {} |
---|
| 63 | |
---|
[1505] | 64 | private: |
---|
| 65 | CommandExecutor() {} |
---|
| 66 | CommandExecutor(const CommandExecutor& other); |
---|
| 67 | ~CommandExecutor() {} |
---|
| 68 | |
---|
| 69 | static CommandExecutor& getInstance(); |
---|
[7229] | 70 | |
---|
| 71 | bool getCached(const std::string& command, CommandEvaluation& evaluation); |
---|
| 72 | void cache(const std::string& command, const CommandEvaluation& evaluation); |
---|
| 73 | |
---|
| 74 | struct CacheEntry |
---|
| 75 | { |
---|
| 76 | CommandEvaluation evaluation_; |
---|
| 77 | std::list<std::string>::iterator iterator_; |
---|
| 78 | }; |
---|
| 79 | |
---|
| 80 | std::map<std::string, CacheEntry> cache_; |
---|
| 81 | std::list<std::string> cachelist_; |
---|
[1755] | 82 | }; // tolua_export |
---|
| 83 | } // tolua_export |
---|
[1505] | 84 | |
---|
| 85 | #endif /* _CommandExecutor_H__ */ |
---|