A Multiton IController implementation.
More...
#include <pmvcpp.h>


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 IController * | getInstance (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 | |
| IView * | view |
| std::map< int, ICommand * > | commandMap |
A Multiton IController implementation.
In PureMVC, the Controller class follows the 'Command and Controller' strategy, and assumes these responsibilities:
ICommands are intended to handle which INotifications. IObserver with the View for each INotification that it has an ICommand mapping for. ICommand to handle a given INotification when notified by the View. ICommand's execute method, passing in the INotification. Your application must register ICommands with the Controller.
The simplest way is to subclass Facade, and use its initializeController method to add your registrations.
| 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 )
| Error | Error if instance for this Multiton key has already been constructed |
| void PureMVC::Controller::executeCommand | ( | INotification * | note | ) | [inline] |
If an ICommand has previously been registered to handle a the given INotification, then it is executed.
| note | an INotification |
| IController * Controller::getInstance | ( | std::string | key | ) | [static] |
Controller Multiton Factory method.
Controller | std::string MultitonKeyHeir::getMultitonKey | ( | ) | [virtual, inherited] |
Get multiton key.
Returns the multiton key.
Implements PureMVC::IMultitonKeyHeir.
| bool Controller::hasCommand | ( | int | notificationName | ) | [virtual] |
Check if a Command is registered for a given Notification.
| notificationName |
notificationName. Implements PureMVC::IController.
| void Controller::initializeController | ( | ) | [protected] |
| 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
| notificationName | the name of the INotification |
| void Controller::removeCommand | ( | int | notificationName | ) | [virtual] |
Remove a previously registered ICommand to INotification mapping.
| 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.
| multitonKey | of IController instance to remove |
| void MultitonKeyHeir::setMultitonKey | ( | std::string | key | ) | [virtual, inherited] |
Set multiton key.
Sets the multiton key.
| key | The name of the key |
Implements PureMVC::IMultitonKeyHeir.
1.6.1