Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/core/CommandEvaluation.h @ 1341

Last change on this file since 1341 was 1341, checked in by landauf, 16 years ago

big commit, but not much changes in code:

  • put CommandEvaluation into it's own .cc and .h files
  • put some basic ConsoleCommands into ConsoleCommandCompilation.cc and .h
  • created a new class, ConsoleCommand, inheriting from ExecutorStatic, implementing all command-related features that were located in the Executor until now (at the moment only accessLevel_, but more will come - from reto and me)
  • renamed ConsoleCommand-macros to SetConsoleCommand (all related macros were changed the same way)
  • added a new command named "killdelays", that kills all delayed commands. helpful to stop disco ;)
File size: 3.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 _CommandEvaluation_H__
30#define _CommandEvaluation_H__
31
32#include "CorePrereqs.h"
33
34#include <string>
35#include <list>
36
37#include "util/SubString.h"
38#include "util/MultiTypeMath.h"
39
40namespace orxonox
41{
42    enum CommandState
43    {
44        CS_Uninitialized,
45        CS_Empty,
46        CS_FunctionClass_Or_Shortcut_Or_Keyword,
47        CS_Shortcut_Params,
48        CS_Shortcut_Finished,
49        CS_Function,
50        CS_Function_Params,
51        CS_Function_Finished,
52        CS_ConfigValueClass,
53        CS_ConfigValue,
54        CS_ConfigValueType,
55        CS_ConfigValueFinished,
56        CS_KeybindKey,
57        CS_KeybindCommand,
58        CS_KeybindFinished,
59        CS_Error
60    };
61
62    enum KeybindMode {}; // temporary
63
64    class _CoreExport CommandEvaluation
65    {
66        friend class CommandExecutor;
67
68        public:
69            CommandEvaluation();
70
71            KeybindMode getKeybindMode();
72            bool isValid() const;
73
74            inline void setAdditionalParameter(const std::string& param)
75                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
76            inline std::string getAdditionalParameter() const
77                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
78
79            void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
80            MultiTypeMath getEvaluatedParameter(unsigned int index) const;
81
82            void evaluateParams();
83
84            bool hasReturnvalue() const;
85            MultiTypeMath getReturnvalue() const;
86
87        private:
88            std::string processedCommand_;
89            SubString tokens_;
90            std::string additionalParameter_;
91
92            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctionClasses_;
93            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleShortcuts_;
94            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
95            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleConfigValueClasses_;
96            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleConfigValues_;
97            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleKeys_;
98
99            Identifier* functionclass_;
100            Identifier* configvalueclass_;
101            ConsoleCommand* shortcut_;
102            ConsoleCommand* function_;
103            ConfigValueContainer* configvalue_;
104            ConfigValueContainer* key_;
105
106            std::string errorMessage_;
107            CommandState state_;
108
109            bool bEvaluatedParams_;
110            MultiTypeMath param_[5];
111            ConsoleCommand* evaluatedExecutor_;
112    };
113}
114
115#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.