#import <MacroCommand.h>
Inherits Notifier, and ICommand-p.
Public Member Functions | |
| (id) | - init |
| (void) | - initializeMacroCommand |
| (void) | - addSubCommand: |
| (void) | - execute: [implementation] |
| (void) | - sendNotification:body:type: [implementation] |
Static Public Member Functions | |
| (id) | + command |
ICommand implementation that executes other ICommands.
A MacroCommand maintains an list of ICommand Class references called SubCommands.
When execute is called, the MacroCommand instantiates and calls execute on each of its SubCommands turn. Each SubCommand will be passed a reference to the original INotification that was passed to the MacroCommand's execute method.
Unlike SimpleCommand, your subclass should not override execute, but instead, should override the initializeMacroCommand method, calling addSubCommand once for each SubCommand to be executed.
| - (void) addSubCommand: | (Class) | commandClassRef |
Add a SubCommand.
The SubCommands will be called in First In/First Out (FIFO) order.
| commandClassRef | a reference to the Class of the ICommand. |
| + (id) command |
Static Convenience Constructor.
| - (void) execute: | (id<INotification>) | notification | [implementation] |
Execute this MacroCommand's SubCommands.
The SubCommands will be called in First In/First Out (FIFO) order.
| notification | the INotification object to be passsed to each SubCommand. |
Reimplemented from < ICommand >.
| - (id) init |
Constructor.
You should not need to define a constructor, instead, override the initializeMacroCommand method.
If your subclass does define a constructor, be sure to call [super init].
Reimplemented from Notifier.
| - (void) initializeMacroCommand |
Initialize the MacroCommand.
In your subclass, override this method to initialize the MacroCommand's SubCommand list with ICommand class references like this:
// Initialize MyMacroCommand -(void)initializeMacroCommand { [self addSubCommand:[FirstCommand class]]; [self addSubCommand:[SecondCommand class]]; [self addSubCommand:[ThirdCommand class]]; }
Note that SubCommands may be any ICommand implementor, MacroCommands or SimpleCommands are both acceptable.
| - (void) sendNotification: | (NSString *) | notificationName | ||
| body: | (id) | body | ||
| type: | (NSString *) | type | ||
[implementation] |
Create and send an INotification.
Keeps us from having to construct new INotification instances in our implementation code.
| notificationName | the name of the notiification to send | |
| body | the body of the notification | |
| type | the type of the notification |
Reimplemented from < INotifier >.
1.5.7.1