A Multiton IView
implementation.
More...
#include <pmvcpp.h>
Public Member Functions | |
View () | |
Constructor. | |
void | registerObserver (int notificationName, IObserverRestricted *observer) |
Register an IObserverRestricted to be notified of INotifications with a given name. | |
void | notifyObservers (INotification *notification) |
Notify the IObservers for a particular INotification . | |
void | removeObserver (int notificationName, intptr_t contextAddress) |
Remove the observer for a given notifyContext from an observer list for a given Notification name. | |
void | registerMediator (IMediator *mediator) |
Register an IMediator instance with the View . | |
IMediator * | retrieveMediator (std::string mediatorName) |
Retrieve an IMediator from the View . | |
IMediator * | removeMediator (std::string mediatorName) |
Remove an IMediator from the View . | |
bool | hasMediator (std::string mediatorName) |
Check if a Mediator is registered or not. | |
virtual void | setMultitonKey (std::string key) |
Set multiton key. | |
virtual std::string | getMultitonKey () |
Get multiton key. | |
Static Public Member Functions | |
static IView * | getInstance (std::string key) |
View Singleton Factory method. | |
static void | removeView (std::string key) |
Remove an IView instance. | |
Protected Attributes | |
std::map< std::string, IMediator * > | mediatorMap |
std::map< int, std::vector < IObserverRestricted * > > | observerMap |
A Multiton IView
implementation.
In PureMVC, the View
class assumes these responsibilities:
IMediator
instances. IMediators
. IMediators
when they are registered or removed. INotification
in the application. IObservers
to an INotification
's observer list. INotification
. IObservers
of a given INotification
when it broadcast. View::View | ( | ) |
Constructor.
This IView
implementation is a Multiton, so you should not call the constructor directly, but instead call the static Multiton Factory method View.getInstance( multitonKey )
. Unlike the AS3 version of PMVC, if you are going to subclass View, you should stick your initialization code in your subclass constructor. Keep in mind though, that the MultitonKey for this instance does not get set until after the constructor is called from getInstance
.
IView * View::getInstance | ( | std::string | key | ) | [static] |
std::string MultitonKeyHeir::getMultitonKey | ( | ) | [virtual, inherited] |
Get multiton key.
Returns the multiton key.
Implements PureMVC::IMultitonKeyHeir.
bool View::hasMediator | ( | std::string | mediatorName | ) | [virtual] |
Check if a Mediator is registered or not.
mediatorName |
mediatorName
. Implements PureMVC::IView.
void View::notifyObservers | ( | INotification * | notification | ) | [virtual] |
Notify the IObservers
for a particular INotification
.
All previously attached IObservers
for this INotification
's list are notified and are passed a reference to the INotification
in the order in which they were registered.
notification | the INotification to notify IObservers of. |
Implements PureMVC::IView.
void View::registerMediator | ( | IMediator * | mediator | ) | [virtual] |
Register an IMediator
instance with the View
.
Registers the IMediator
so that it can be retrieved by name, and further interrogates the IMediator
for its INotification
interests.
If the IMediator
returns any INotification
names to be notified about, an Observer
is created encapsulating the IMediator
instance's handleNotification
method and registering it as an Observer
for all INotifications
the IMediator
is interested in.
mediatorName | the name to associate with this IMediator instance | |
mediator | a reference to the IMediator instance |
Implements PureMVC::IView.
void View::registerObserver | ( | int | notificationName, | |
IObserverRestricted * | observer | |||
) | [virtual] |
Register an IObserverRestricted
to be notified of INotifications
with a given name.
notificationName | the name of the INotifications to notify this IObserver of | |
observer | the IObserverRestricted to register |
Implements PureMVC::IView.
IMediator * View::removeMediator | ( | std::string | mediatorName | ) | [virtual] |
Remove an IMediator
from the View
.
mediatorName | name of the IMediator instance to be removed. |
mediatorName | name of the IMediator instance to be removed. |
Implements PureMVC::IView.
void View::removeObserver | ( | int | notificationName, | |
intptr_t | contextAddress | |||
) | [virtual] |
Remove the observer for a given notifyContext from an observer list for a given Notification name.
notificationName | which observer list to remove from | |
contextAddress | remove the observer with this memory address as its notifyContext's address |
Implements PureMVC::IView.
void View::removeView | ( | std::string | key | ) | [static] |
IMediator * View::retrieveMediator | ( | std::string | mediatorName | ) | [virtual] |
Retrieve an IMediator
from the View
.
mediatorName | the name of the IMediator instance to retrieve. |
IMediator
instance previously registered with the given mediatorName
. Implements PureMVC::IView.
void MultitonKeyHeir::setMultitonKey | ( | std::string | key | ) | [virtual, inherited] |
Set multiton key.
Sets the multiton key.
key | The name of the key |
Implements PureMVC::IMultitonKeyHeir.