| 1 | = SHELL = |
| 2 | The Shell is an extension to [source:/trunk/src/defs/debug.h debug.h], that allows |
| 3 | the output to be redirected to an opengl shell ontop of an application (orxonox). It is bidirectional to enable the user to |
| 4 | send commands to the application. |
| 5 | |
| 6 | == Structure == |
| 7 | |
| 8 | http://www.orxonox.net/additionals/Shell.png |
| 9 | |
| 10 | * __Application__: |
| 11 | * The Shell is communicating with the application (namely orxonox) through debug.h. E.g. all output can be redirected to the Shell's Buffer. |
| 12 | * Commands can be executed, and the result is sent back to the application via Shell's Commands. |
| 13 | * __Shell Input__: |
| 14 | * Gets input from the user keyboard. |
| 15 | * Command completion: on <TAB> the shell tries to complete either Classes, Objects or Commands |
| 16 | * The input is structured as follows: |
| 17 | * <Class> [Object] <functionCall> [argument1,[argument2,... ]] [[br]] |
| 18 | -- <> MUST BE [[br]] |
| 19 | -- [] optional, depending on the circumstances [[br]] |
| 20 | -- [Object] must be defined, if there exist more than one instance of a certain Class. |
| 21 | * __Display__: |
| 22 | * Renders the Text to the screen (with a nice little background). This is not a Class itself, it is inside the Shell/Shell's Input. |
| 23 | * __Shell Command__: |
| 24 | * An entered Shell Command will be checked for integrity, quality attributes: |
| 25 | 1. Does an instance of the class exist? |
| 26 | 2. More than one -> object required! |
| 27 | 3. Does the function Exist |
| 28 | 4. Are any parameters supplied? |
| 29 | 5. Execute command |
| 30 | |
| 31 | |
| 32 | == Usage == |
| 33 | Create a new Command: nothing easier than this, here an example: |
| 34 | Use the makro function SHELL_COMMENAD(argumen1, argument2, argument3)->describe(argument4); |
| 35 | {{{ |
| 36 | #!cpp |
| 37 | SHELL_COMMAND(clear, Shell, clearShell) |
| 38 | ->describe("Clears the shell's Buffer") |
| 39 | ->setAlias("clear"); |
| 40 | }}} |
| 41 | * Argument 1: the name of the command in the shell (this is what you will enter in the shell), without "" (e.g. clear) |
| 42 | * Argument 2: the name of the class that executes the command, without "" (e.g. Shell) |
| 43 | * Argument 3: the name of the function (without any arguments) to execute on this command (e.g. clearShell) |
| 44 | * Argument 4: (optional) add a little description: a nice little text for the help screen. |
| 45 | * Argument 5: (optional) adds an Alias to this command, that can be used insted of ex. 'Shell clear' |
| 46 | |
| 47 | To use the command: In the Shell type: "Shell clear" or "clear" [[br]] |
| 48 | This will execute the function Shell->clearShell(), which will clear the shell buffer. |
| 49 | As you may have noticed, the Names are !!NOT!! concatenated with any "", this is because the above mentioned method uses a MACRO to register the Command. Further, it is important to note, that {{{SHELL_COMMAND(...)}}} is not an object function, it is actually called within the class. |
| 50 | |
| 51 | |
| 52 | Background Knowledge: the macro unrolled: |
| 53 | {{{ |
| 54 | #!cpp |
| 55 | #define SHELL_COMMAND(command, class, function) \ |
| 56 | ShellCommandBase* shell_command_##class##_##command = \ |
| 57 | ShellCommand<class>::registerCommand(#command, #class, &class::function) |
| 58 | |
| 59 | /* MEANING: |
| 60 | ShellCommandBase* someUniqueVarName = |
| 61 | ShellCommand<ClassName>::registerCommand("commandNameInShell", "ClassName", &ClassName::FunctionToCall); |
| 62 | */ |
| 63 | }}} |
| 64 | This can also be called with arguments, for default values (##FIXME##) |
| 65 | |
| 66 | |
| 67 | == Dependencies == |
| 68 | * [wiki:TextEngine Text] -> [wiki:Element2D Element2D] ->BaseObject |
| 69 | * EvenentListener (for input) |
| 70 | * ClassList (List) |
| 71 | |
| 72 | == Responsible == |
| 73 | bensch (see source for email) |