1 | /*! |
---|
2 | * @file shell_command_class.h |
---|
3 | * Definition of a on-screen-shell |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _SHELL_COMMAND_CLASS_H |
---|
7 | #define _SHELL_COMMAND_CLASS_H |
---|
8 | |
---|
9 | #include "base_object.h" |
---|
10 | #include <vector> |
---|
11 | #include <list> |
---|
12 | |
---|
13 | namespace OrxShell |
---|
14 | { |
---|
15 | // FORWARD DECLARATION |
---|
16 | class ShellCommand; |
---|
17 | class ShellCommandAlias; |
---|
18 | class ShellCommandClass; |
---|
19 | |
---|
20 | typedef std::vector<ShellCommand*> CmdList; |
---|
21 | typedef std::vector<ShellCommandClass*> CmdClassList; |
---|
22 | |
---|
23 | |
---|
24 | //! A class to hold all Classes that have (once) registered Commands. |
---|
25 | class ShellCommandClass : public BaseObject |
---|
26 | { |
---|
27 | friend class ShellCommand; |
---|
28 | public: |
---|
29 | /** @returns the CommandClassList */ |
---|
30 | static const CmdClassList& getCommandClassList() { return *ShellCommandClass::commandClassList; }; |
---|
31 | |
---|
32 | static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList); |
---|
33 | |
---|
34 | static void unregisterAllCommands(); |
---|
35 | static ShellCommandClass* getCommandClass(const std::string& className); |
---|
36 | ClassID getClassID(); |
---|
37 | static bool exists(const std::string& className); |
---|
38 | |
---|
39 | static void help (const std::string& className = ""); |
---|
40 | |
---|
41 | static void debug(); |
---|
42 | |
---|
43 | private: |
---|
44 | ShellCommandClass(const std::string& className); |
---|
45 | static ShellCommandClass* acquireCommandClass(const std::string& className); |
---|
46 | virtual ~ShellCommandClass(); |
---|
47 | |
---|
48 | |
---|
49 | void registerCommand(ShellCommand* command); |
---|
50 | void unregisterCommand(ShellCommand* command); |
---|
51 | |
---|
52 | private: |
---|
53 | const std::string className; //!< The Name of the Class. This should match the ClassName of the Commands Class. |
---|
54 | ClassID classID; //!< The classID of this Class |
---|
55 | CmdList commandList; //!< A list of Commands from this Class |
---|
56 | |
---|
57 | static CmdClassList* commandClassList; //!< A list of Classes |
---|
58 | }; |
---|
59 | } |
---|
60 | |
---|
61 | #endif /* _SHELL_COMMAND_H */ |
---|