Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h @ 7202

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

moved all files related to the command execution chain to core/command (includes not yet adjusted, doesn't compile)

  • Property svn:eol-style set to native
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 "ArgumentCompletionListElement.h"
38#include "util/SubString.h"
39#include "util/MultiType.h"
40
41namespace orxonox
42{
43    namespace CommandState
44    {
45        enum Value
46        {
47            Uninitialized,
48            Empty,
49            ShortcutOrIdentifier,
50            Function,
51            ParamPreparation,
52            Params,
53            Finished,
54            Error
55        };
56    }
57
58    class _CoreExport CommandEvaluation
59    {
60        friend class CommandExecutor;
61
62        public:
63            CommandEvaluation();
64
65            void initialize(const std::string& command);
66
67            bool execute() const;
68            MultiType query(bool* success = 0) const;
69
70            const std::string& complete();
71            std::string hint() const;
72            void evaluateParams();
73
74            bool isValid() const;
75
76            inline ConsoleCommand* getConsoleCommand() const
77                { return this->function_; }
78            inline const std::string& getOriginalCommand() const
79                { return this->originalCommand_; }
80            inline const std::string& getCommand() const
81                { return this->command_; }
82
83            inline void setAdditionalParameter(const std::string& param)
84                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
85            inline std::string getAdditionalParameter() const
86                { return (!this->additionalParameter_.empty()) ? (' ' + this->additionalParameter_) : ""; }
87
88            void setEvaluatedParameter(unsigned int index, MultiType param);
89            MultiType getEvaluatedParameter(unsigned int index) const;
90
91        private:
92            unsigned int getStartindex() const;
93            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
94            static std::string dump(const ArgumentCompletionList& list);
95            static std::string dump(const ConsoleCommand* command);
96
97
98            bool bNewCommand_;
99            bool bCommandChanged_;
100
101            std::string originalCommand_;
102            std::string command_;
103            SubString commandTokens_;
104            std::string additionalParameter_;
105
106            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
107            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
108            ArgumentCompletionList listOfPossibleArguments_;
109
110            Identifier* functionclass_;
111            ConsoleCommand* function_;
112            std::string possibleArgument_;
113            std::string argument_;
114
115            std::string errorMessage_;
116            CommandState::Value state_;
117
118            bool bEvaluatedParams_;
119            MultiType param_[5];
120    };
121}
122
123#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.