PureMVC.Core.Controller Class Reference

A Singleton IController implementation. More...

Inheritance diagram for PureMVC.Core.Controller:

PureMVC.Interfaces.IController

List of all members.

Public Member Functions

virtual void ExecuteCommand (INotification note)
 If an ICommand has previously been registered to handle a the given INotification, then it is executed.
virtual void RegisterCommand (string notificationName, Type commandType)
 Register a particular ICommand class as the handler for a particular INotification.
virtual bool HasCommand (string notificationName)
 Check if a Command is registered for a given Notification.
virtual void RemoveCommand (string notificationName)
 Remove a previously registered ICommand to INotification mapping.

Protected Member Functions

 Controller ()
virtual void InitializeController ()
 Initialize the Singleton Controller instance.

Protected Attributes

IView m_view
IDictionary< string, Type > m_commandMap
 Mapping of Notification names to Command Class references.
readonly object m_syncRoot = new object()
 Used for locking.

Static Protected Attributes

static volatile IController m_instance
 Singleton instance, can be sublcassed though....
static readonly object m_staticSyncRoot = new object()
 Used for locking the instance calls.

Properties

static IController Instance [get]
 Singleton Factory method. This method is thread safe.


Detailed Description

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

PureMVC.Core.View PureMVC.Patterns.Observer PureMVC.Patterns.Notification PureMVC.Patterns.SimpleCommand PureMVC.Patterns.MacroCommand


Constructor & Destructor Documentation

PureMVC.Core.Controller.Controller (  )  [protected]

Constructs and initializes a new controller

This IController implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory method Controller.getInstance()


Member Function Documentation

virtual void PureMVC.Core.Controller.ExecuteCommand ( INotification  note  )  [virtual]

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

Parameters:
note An INotification
This method is thread safe and needs to be thread safe in all implementations.

Implements PureMVC.Interfaces.IController.

virtual bool PureMVC.Core.Controller.HasCommand ( string  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.
This method is thread safe and needs to be thread safe in all implementations.

Implements PureMVC.Interfaces.IController.

virtual void PureMVC.Core.Controller.InitializeController (  )  [protected, virtual]

Initialize the Singleton Controller instance.

Called automatically by the constructor

Note that if you are using a subclass of View in your application, you should also subclass Controller and override the initializeController method in the following way:

ensure that the Controller is talking to my IView implementation public override void initializeController() { view = MyView.Instance; }

virtual void PureMVC.Core.Controller.RegisterCommand ( string  notificationName,
Type  commandType 
) [virtual]

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

Parameters:
notificationName The name of the INotification
commandType The Type of the ICommand

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

This method is thread safe and needs to be thread safe in all implementations.

Implements PureMVC.Interfaces.IController.

virtual void PureMVC.Core.Controller.RemoveCommand ( string  notificationName  )  [virtual]

Remove a previously registered ICommand to INotification mapping.

Parameters:
notificationName The name of the INotification to remove the ICommand mapping for
This method is thread safe and needs to be thread safe in all implementations.

Implements PureMVC.Interfaces.IController.


Member Data Documentation

IDictionary<string, Type> PureMVC.Core.Controller.m_commandMap [protected]

Mapping of Notification names to Command Class references.

volatile IController PureMVC.Core.Controller.m_instance [static, protected]

Singleton instance, can be sublcassed though....

readonly object PureMVC.Core.Controller.m_staticSyncRoot = new object() [static, protected]

Used for locking the instance calls.

readonly object PureMVC.Core.Controller.m_syncRoot = new object() [protected]

Used for locking.

Local reference to View


Property Documentation

IController PureMVC.Core.Controller.Instance [static, get]

Singleton Factory method. This method is thread safe.


The documentation for this class was generated from the following file:

Generated on Thu Jan 1 16:26:45 2009 for PureMVC by  doxygen 1.5.8