| 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 | |
|---|
| 12 | |
|---|
| 13 | namespace OrxShell |
|---|
| 14 | { |
|---|
| 15 | // FORWARD DECLARATION |
|---|
| 16 | class ShellCommand; |
|---|
| 17 | class ShellCommandAlias; |
|---|
| 18 | |
|---|
| 19 | //! A class to hold all Classes that have (once) registered Commands. |
|---|
| 20 | class ShellCommandClass : public BaseObject |
|---|
| 21 | { |
|---|
| 22 | friend class ShellCommand; |
|---|
| 23 | |
|---|
| 24 | public: |
|---|
| 25 | /** @returns the CommandClassList */ |
|---|
| 26 | static const std::vector<ShellCommandClass*>& getCommandClassList() { return ShellCommandClass::commandClassList; }; |
|---|
| 27 | |
|---|
| 28 | static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList); |
|---|
| 29 | |
|---|
| 30 | static void unregisterAllCommands(); |
|---|
| 31 | static const ShellCommandClass* getCommandClass(const std::string& className); |
|---|
| 32 | ClassID getClassID(); |
|---|
| 33 | static bool exists(const std::string& className); |
|---|
| 34 | |
|---|
| 35 | static void help (const std::string& className); |
|---|
| 36 | |
|---|
| 37 | private: |
|---|
| 38 | ShellCommandClass(const std::string& className); |
|---|
| 39 | static ShellCommandClass* acquireCommandClass(const std::string& className); |
|---|
| 40 | virtual ~ShellCommandClass(); |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | void registerCommand(ShellCommand* command); |
|---|
| 44 | void unregisterCommand(ShellCommand* command); |
|---|
| 45 | |
|---|
| 46 | private: |
|---|
| 47 | const std::string className; //!< The Name of the Class. This should match the ClassName of the Commands Class. |
|---|
| 48 | ClassID classID; //!< The classID of this Class |
|---|
| 49 | std::vector<ShellCommand*> commandList; //!< A list of Commands from this Class |
|---|
| 50 | |
|---|
| 51 | static std::vector<ShellCommandClass*> commandClassList; //!< A list of Classes |
|---|
| 52 | }; |
|---|
| 53 | |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | #endif /* _SHELL_COMMAND_H */ |
|---|