Package puremvc :: Package patterns :: Module command :: Class MacroCommand
[hide private]
[frames] | no frames]

type MacroCommand

source code

              object --+    
                       |    
interfaces.INotifier --+    
                       |    
       observer.Notifier --+
                           |
     interfaces.ICommand --+
                           |
    interfaces.INotifier --+
                           |
                          MacroCommand

A base 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.


See Also:
Controller, Notification, SimpleCommand
Instance Methods [hide private]
 
__init__(self)
MacroCommand Constructor
source code
 
initializeMacroCommand(self)
Initialize the MacroCommand.
source code
 
addSubCommand(self, commandClassRef)
Add a SubCommand.
source code
 
execute(self, notification)
Execute this MacroCommand's SubCommands.
source code

Inherited from observer.Notifier: sendNotification

Class Variables [hide private]
  subCommands = None

Inherited from observer.Notifier: facade

Method Details [hide private]

__init__(self)
(Constructor)

source code 

MacroCommand Constructor

You should not need to define a constructor, instead, override the initializeMacroCommand method.

Overrides: observer.Notifier.__init__

initializeMacroCommand(self)

source code 

Initialize the MacroCommand.

In your subclass, override this method to initialize the MacroCommand's SubCommand list with ICommand class references like this:

Note that SubCommands may be any ICommand implementor, MacroCommands or SimpleCommands are both acceptable.

addSubCommand(self, commandClassRef)

source code 

Add a SubCommand.

The SubCommands will be called in First In/First Out (FIFO) order.

Parameters:
  • commandClassRef - a reference to the Class of the ICommand.

execute(self, notification)

source code 

Execute this MacroCommand's SubCommands.

The SubCommands will be called in First In/First Out (FIFO) order.

Parameters:
  • notification - the INotification object to be passsed to each SubCommand.
Overrides: interfaces.ICommand.execute