A Command is a named function, executed by the CommandInterpreter. More...
#include <Command.h>
Public Member Functions | |
| Command (const string &name, const string &argumentFormat) | |
| Constructs a Command. More... | |
| virtual | ~Command ()=0 |
| const string & | GetCommandName () const |
| Gets the name of the command. More... | |
| const string & | GetArgumentFormat () const |
| Gets the argument format for the command. More... | |
| virtual bool | Execute (GXemul &gxemul, const vector< string > &arguments)=0 |
| Executes the command on a given GXemul instance. More... | |
| virtual bool | MayBeReexecutedWithoutArgs () const |
| Returns whether the command can be quickly re-executed using an empty command line. More... | |
| virtual string | GetShortDescription () const =0 |
| Returns a short (one-line) description of the command. More... | |
| virtual string | GetLongDescription () const =0 |
| Returns a long description/help message for the command. More... | |
Public Member Functions inherited from ReferenceCountable | |
| ReferenceCountable () | |
| Default constructor, which initializes the reference count to zero. More... | |
| ~ReferenceCountable () | |
Static Public Member Functions | |
| static void | RunUnitTests (int &nSucceeded, int &nFailures) |
Static Public Member Functions inherited from UnitTestable | |
| static void | RunUnitTests (int &nSucceeded, int &nFailures) |
| Runs unit test cases. More... | |
A Command is a named function, executed by the CommandInterpreter.
To implement a new Command, simply create the corresponding .h file in src/include/commands/ and a .cc file in src/main/commands/ (e.g. by copying from a similar command), and add the name of the command's .o file to src/main/commands/Makefile.skel. (The configure script takes care of adding all commands to the CommandInterpreter, so there is no need to manually "register" the command anywhere.)
| Command::Command | ( | const string & | name, |
| const string & | argumentFormat | ||
| ) |
Constructs a Command.
| name | The command's name. This should be a unique lower-case string, consisting only of letters a-z. |
| argumentFormat | A string describing the command's arguments. May be empty, if the command takes no arguments. |
Definition at line 32 of file Command.cc.
|
pure virtual |
Definition at line 39 of file Command.cc.
|
pure virtual |
Executes the command on a given GXemul instance.
| gxemul | A reference to the GXemul instance. |
| arguments | A vector of zero or more string arguments. |
Implemented in ResetCommand, StatusCommand, AddComponentCommand, ContinueCommand, CopyComponentCommand, LoadCommand, MoveComponentCommand, PauseCommand, RemoveComponentCommand, BackwardStepCommand, CloseCommand, ContinueBackwardsCommand, HelpCommand, ListComponentsCommand, QuitCommand, SaveCommand, StepCommand, and VersionCommand.
|
inline |
Gets the argument format for the command.
Definition at line 80 of file Command.h.
Referenced by HelpCommand::Execute().
|
inline |
Gets the name of the command.
Definition at line 70 of file Command.h.
Referenced by CommandInterpreter::AddCommand(), and HelpCommand::Execute().
|
pure virtual |
Returns a long description/help message for the command.
Implemented in BackwardStepCommand, StepCommand, ResetCommand, StatusCommand, AddComponentCommand, ContinueCommand, CopyComponentCommand, LoadCommand, MoveComponentCommand, PauseCommand, RemoveComponentCommand, CloseCommand, ContinueBackwardsCommand, HelpCommand, ListComponentsCommand, QuitCommand, SaveCommand, and VersionCommand.
|
pure virtual |
Returns a short (one-line) description of the command.
Implemented in BackwardStepCommand, StepCommand, ResetCommand, StatusCommand, AddComponentCommand, ContinueCommand, CopyComponentCommand, LoadCommand, MoveComponentCommand, PauseCommand, RemoveComponentCommand, CloseCommand, ContinueBackwardsCommand, HelpCommand, ListComponentsCommand, QuitCommand, SaveCommand, and VersionCommand.
Referenced by HelpCommand::Execute().
|
inlinevirtual |
Returns whether the command can be quickly re-executed using an empty command line.
Typical examples are: step, cpu disassembly, and memory dump, where re-executing the command without arguments is very natural.
Reimplemented in BackwardStepCommand, and StepCommand.
|
static |
1.8.17