PureMVC::Controller Class Reference

A Multiton IController implementation. More...

#include <pmvcpp.h>

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

List of all members.

Public Member Functions

 Controller ()
 Constructor.
template<class T >
void executeCommand (INotification *note)
 If an ICommand has previously been registered to handle a the given INotification, then it is executed.
template<class T >
void registerCommand (int notificationName)
 Register a particular ICommand class as the handler for a particular INotification.
bool hasCommand (int notificationName)
 Check if a Command is registered for a given Notification.
void removeCommand (int notificationName)
 Remove a previously registered ICommand to INotification mapping.
virtual void setMultitonKey (std::string key)
 Set multiton key.
virtual std::string getMultitonKey ()
 Get multiton key.

Static Public Member Functions

static IControllergetInstance (std::string key)
 Controller Multiton Factory method.
static void removeController (std::string key)
 Remove an IController instance.

Protected Member Functions

void initializeController ()
 Initialize the Multiton Controller instance.

Protected Attributes

IViewview
std::map< int, ICommand * > commandMap

Detailed Description

A Multiton IController implementation.

In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities:

Your application must register ICommands with the Controller.

The simplest way is to subclass Facade, and use its initializeController method to add your registrations.

See also:
View
Observer
Notification
SimpleCommand
MacroCommand

Constructor & Destructor Documentation

Controller::Controller (  ) 

Constructor.

This IController implementation is a Multiton, so you should not call the constructor directly, but instead call the static Factory method, passing the unique key for this instance Controller.getInstance( multitonKey )

Exceptions:
Error Error if instance for this Multiton key has already been constructed

Member Function Documentation

template<class T >
void PureMVC::Controller::executeCommand ( INotification note  )  [inline]

If an ICommand has previously been registered to handle a the given INotification, then it is executed.

Parameters:
note an INotification
IController * Controller::getInstance ( std::string  key  )  [static]

Controller Multiton Factory method.

Returns:
the Multiton instance of Controller
std::string MultitonKeyHeir::getMultitonKey (  )  [virtual, inherited]

Get multiton key.

Returns the multiton key.

Returns:
The string key name

Implements PureMVC::IMultitonKeyHeir.

bool Controller::hasCommand ( int  notificationName  )  [virtual]

Check if a Command is registered for a given Notification.

Parameters:
notificationName 
Returns:
whether a Command is currently registered for the given notificationName.

Implements PureMVC::IController.

void Controller::initializeController (  )  [protected]

Initialize the Multiton Controller instance.

Called automatically by the getInstance

Returns:
void
template<class T >
void PureMVC::Controller::registerCommand ( int  notificationName  )  [inline]

Register a particular ICommand class as the handler for a particular INotification.

If an ICommand has already been registered to handle INotifications with this name, it is no longer used, the new ICommand is used instead.

The Observer for the new ICommand is only created if this the first time an ICommand has been regisered for this Notification name.

commandClassRef the Class of the ICommand

Parameters:
notificationName the name of the INotification
void Controller::removeCommand ( int  notificationName  )  [virtual]

Remove a previously registered ICommand to INotification mapping.

Parameters:
notificationName the name of the INotification to remove the ICommand mapping for

Implements PureMVC::IController.

void Controller::removeController ( std::string  key  )  [static]

Remove an IController instance.

Parameters:
multitonKey of IController instance to remove
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.


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

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