PureMVC::MacroCommand Class Reference

A base ICommand implementation that executes other ICommands. More...

#include <pmvcpp.h>

Inheritance diagram for PureMVC::MacroCommand:
Inheritance graph
[legend]
Collaboration diagram for PureMVC::MacroCommand:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MacroCommand ()
 Constructor.
void execute (INotification *notification)
 Execute this MacroCommand's SubCommands.
void sendNotification (int notificationName, void *body, int notificationType)
 Create and send an INotification.
void sendNotification (int notificationName, int notificationType)
 Send a INotification.
void sendNotification (int notificationName, void *body)
 Send a INotification.
void sendNotification (int notificationName)
 Send a INotification.
void initializeNotifier (std::string key)
 Initialize this INotifier instance.
virtual void setMultitonKey (std::string key)
 Set multiton key.
virtual std::string getMultitonKey ()
 Get multiton key.

Protected Member Functions

void addSubCommand (ICommand *command)
 Initialize the MacroCommand.
IFacadegetFacade ()

Protected Attributes

std::vector< ICommand * > subCommands
 Subcommands.

Detailed Description

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

Constructor & Destructor Documentation

MacroCommand::MacroCommand (  ) 

Constructor.

You need to define a constructor, and add all your subcommands within it.

In your subclass, define a constuctor to initialize the MacroCommand's SubCommand list with ICommand class references like this:

<listing> // Initialize MyMacroCommand MacroCommandSubclass::MacroCommandSubclass( ) { this->addSubCommand( new FirstCommand() ); this->addSubCommand( new SecondCommand() ); this->addSubCommand( new ThirdCommand() ); } </listing>

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


Member Function Documentation

void MacroCommand::addSubCommand ( ICommand command  )  [protected]

Initialize the MacroCommand.

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

<listing> // Initialize MyMacroCommand override protected function initializeMacroCommand( ) : void { addSubCommand( com.me.myapp.controller.FirstCommand ); addSubCommand( com.me.myapp.controller.SecondCommand ); addSubCommand( com.me.myapp.controller.ThirdCommand ); } </listing>

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

void MacroCommand::execute ( INotification notification  )  [virtual]

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.

Implements PureMVC::SimpleCommand.

std::string MultitonKeyHeir::getMultitonKey (  )  [virtual, inherited]

Get multiton key.

Returns the multiton key.

Returns:
The string key name

Implements PureMVC::IMultitonKeyHeir.

void Notifier::initializeNotifier ( std::string  key  )  [virtual, inherited]

Initialize this INotifier instance.

This is how a Notifier gets its multitonKey. Calls to sendNotification or to access the facade will fail until after this method has been called.

Mediators, Commands or Proxies may override this method in order to send notifications or access the Multiton Facade instance as soon as possible. They CANNOT access the facade in their constructors, since this method will not yet have been called.

Parameters:
key the multitonKey for this INotifier to use

Implements PureMVC::INotifier.

void Notifier::sendNotification ( int  notificationName  )  [virtual, inherited]

Send a INotification.

Convenience method to prevent having to construct new notification instances in our implementation code.

Parameters:
notificationName the name of the notification to send

Implements PureMVC::INotifier.

void Notifier::sendNotification ( int  notificationName,
void *  body 
) [virtual, inherited]

Send a INotification.

Convenience method to prevent having to construct new notification instances in our implementation code.

Parameters:
notificationName the name of the notification to send
body the body of the notification (optional)

Implements PureMVC::INotifier.

void Notifier::sendNotification ( int  notificationName,
int  notificationType 
) [virtual, inherited]

Send a INotification.

Convenience method to prevent having to construct new notification instances in our implementation code.

Parameters:
notificationName the name of the notification to send
type the type of the notification (optional)

Implements PureMVC::INotifier.

void Notifier::sendNotification ( int  notificationName,
void *  body,
int  notificationType 
) [virtual, inherited]

Create and send an INotification.

Keeps us from having to construct new INotification instances in our implementation code.

Parameters:
notificationName the name of the notiification to send
body the body of the notification (optional)
type the type of the notification (optional)

Implements PureMVC::INotifier.

void MultitonKeyHeir::setMultitonKey ( std::string  key  )  [virtual, inherited]

Set multiton key.

Sets the multiton key.

Parameters:
key The name of the key

Implements PureMVC::IMultitonKeyHeir.


Member Data Documentation

std::vector<ICommand*> PureMVC::MacroCommand::subCommands [protected]

Subcommands.

Holds all the subcommands.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables

Generated on Wed Feb 17 17:11:32 2010 for PureMVC++ by  doxygen 1.6.1