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