|
|
A base class for implementing the 'Command' design pattern [Gof]
If you are implementing a new Command then inherit publicly from this class, implement the executeImpl() and undoImpl() methods and ensure that your constructor calls the Command protected constructor.
~Command ()
| ~Command |
[virtual]
void execute ()
| execute |
Call this to execute the Command.
If the Command has already been executed, nothing will happen.
See also: undo
void undo ()
| undo |
Call this to undo the Command.
If the Command can't be undone, or it has already been undone, then nothing will happen.
const std::string & title ()
| title |
[const]
Returns a descriptive string for the command.
The string begins with a lower case letter and is capable of following "Undo " or "Redo ".
bool undoable ()
| undoable |
[const]
Returns whether this Command is capable of being undone.
bool done ()
| done |
[const]
Returns whether this command has been executed.
See also: execute, undo
Command (const std::string &title, bool undoable = true)
| Command |
[protected]
Create a Command with a descriptive string. This must begin with a lower case letter and be capable of following "Undo " or "Redo ".
Parameters:
title | Name for Command |
undoable | Whether the Command is undoable |
void executeImpl ()
| executeImpl |
[protected pure virtual]
Implementations of Command override this method to implement the execute action.
void undoImpl ()
| undoImpl |
[protected pure virtual]
Implementations of Command override this method to implement to undo action.
void setTitle (const std::string &title)
| setTitle |
[protected]
Sets the Command title. Normally you will do this in the ctor and never use this.