A base Multiton IFacade
implementation.
More...
#include <pmvcpp.h>
Public Member Functions | |
Facade () | |
Constructor. | |
template<class T > | |
void | registerCommand (int notificationName) |
Register an ICommand with the Controller by Notification name. | |
void | removeCommand (int notificationName) |
Remove a previously registered ICommand to INotification mapping from the Controller. | |
bool | hasCommand (int notificationName) |
Check if a Command is registered for a given Notification. | |
void | registerProxy (IProxy *proxy) |
Register an IProxy with the Model by name. | |
IProxy * | retrieveProxy (std::string proxyName) |
Retrieve an IProxy from the Model by name. | |
IProxy * | removeProxy (std::string proxyName) |
Remove an IProxy from the Model by name. | |
bool | hasProxy (std::string proxyName) |
Check if a Proxy is registered. | |
void | registerMediator (IMediator *mediator) |
Register a IMediator 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. | |
void | sendNotification (int notificationName, void *body, int notificationType) |
Create and send an INotification . | |
void | sendNotification (int notificationName, void *body) |
Send a INotification . | |
void | sendNotification (int notificationName, int notificationType) |
Send a INotification . | |
void | sendNotification (int notificationName) |
Send a INotification . | |
void | notifyObservers (INotification *notification) |
Notify Observer s. | |
void | initializeNotifier (std::string key) |
Set the Multiton key for this facade instance. | |
virtual void | setMultitonKey (std::string key)=0 |
Set multiton key. | |
virtual std::string | getMultitonKey ()=0 |
Get multiton key. | |
virtual void | setMultitonKey (std::string key) |
Set multiton key. | |
virtual std::string | getMultitonKey () |
Get multiton key. | |
Static Public Member Functions | |
static Facade * | getInstance (std::string) |
Facade multiton factory method. | |
static bool | hasCore (std::string key) |
Check if a Core is registered or not. | |
static void | removeCore (std::string key) |
Remove a Core. | |
Protected Member Functions | |
void | initializeFacade () |
Initialize the Multiton Facade instance. | |
void | initializeController () |
Initialize the Controller . | |
void | initializeModel () |
Initialize the Model . | |
void | initializeView () |
Initialize the View . | |
Protected Attributes | |
IController * | controller |
IModel * | model |
IView * | view |
A base Multiton IFacade
implementation.
Facade::Facade | ( | ) |
Constructor.
This IFacade
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 Facade.getInstance( multitonKey )
Error | Error if instance for this Multiton key has already been constructed |
Facade * Facade::getInstance | ( | std::string | key | ) | [static] |
std::string MultitonKeyHeir::getMultitonKey | ( | ) | [virtual, inherited] |
Get multiton key.
Returns the multiton key.
Implements PureMVC::IMultitonKeyHeir.
virtual std::string PureMVC::IMultitonKeyHeir::getMultitonKey | ( | ) | [pure virtual, inherited] |
Get multiton key.
Returns the multiton key.
Implemented in PureMVC::MultitonKeyHeir.
bool Facade::hasCommand | ( | int | notificationName | ) | [virtual] |
Check if a Command is registered for a given Notification.
notificationName |
notificationName
. Implements PureMVC::IFacade.
bool Facade::hasCore | ( | std::string | key | ) | [static] |
Check if a Core is registered or not.
key | the multiton key for the Core in question |
key
. bool Facade::hasMediator | ( | std::string | mediatorName | ) | [virtual] |
Check if a Mediator is registered or not.
mediatorName |
mediatorName
. Implements PureMVC::IFacade.
bool Facade::hasProxy | ( | std::string | proxyName | ) | [virtual] |
Check if a Proxy is registered.
proxyName |
proxyName
. Implements PureMVC::IFacade.
void Facade::initializeController | ( | ) | [protected] |
Initialize the Controller
.
Called by the initializeFacade
method. Override this method in your subclass of Facade
if one or both of the following are true:
IController
. Commands
to register with the Controller
at startup.. If you don't want to initialize a different IController
, call super.initializeController()
at the beginning of your method, then register Command
s.
void Facade::initializeFacade | ( | ) | [protected] |
void Facade::initializeModel | ( | ) | [protected] |
Initialize the Model
.
Called by the initializeFacade
method. Override this method in your subclass of Facade
if one or both of the following are true:
IModel
. Proxy
s to register with the Model that do not retrieve a reference to the Facade at construction time. If you don't want to initialize a different IModel
, call super.initializeModel()
at the beginning of your method, then register Proxy
s.
Note: This method is rarely overridden; in practice you are more likely to use a Command
to create and register Proxy
s with the Model
, since Proxy
s with mutable data will likely need to send INotification
s and thus will likely want to fetch a reference to the Facade
during their construction.
void Facade::initializeNotifier | ( | std::string | key | ) | [virtual] |
Set the Multiton key for this facade instance.
Not called directly, but instead when getInstance is invoked. It is necessary to be public in order to implement INotifier.
Implements PureMVC::INotifier.
void Facade::initializeView | ( | ) | [protected] |
Initialize the View
.
Called by the initializeFacade
method. Override this method in your subclass of Facade
if one or both of the following are true:
If you don't want to initialize a different IView
, call super.initializeView()
at the beginning of your method, then register IMediator
instances.
Note: This method is rarely overridden; in practice you are more likely to use a Command
to create and register Mediator
s with the View
, since IMediator
instances will need to send INotification
s and thus will likely want to fetch a reference to the Facade
during their construction.
void Facade::notifyObservers | ( | INotification * | notification | ) | [virtual] |
Notify Observer
s.
This method is left public mostly for backward compatibility, and to allow you to send custom notification classes using the facade.
Usually you should just call sendNotification and pass the parameters, never having to construct the notification yourself.
notification | the INotification to have the View notify Observers of. |
Implements PureMVC::IFacade.
void PureMVC::Facade::registerCommand | ( | int | notificationName | ) | [inline] |
Register an ICommand
with the Controller
by Notification name.
commandClassRef a reference to the Class of the ICommand
notificationName | the name of the INotification to associate the ICommand with |
void Facade::registerMediator | ( | IMediator * | mediator | ) | [virtual] |
Register a IMediator
with the View
.
mediatorName | the name to associate with this IMediator | |
mediator | a reference to the IMediator |
Implements PureMVC::IFacade.
void Facade::registerProxy | ( | IProxy * | proxy | ) | [virtual] |
void Facade::removeCommand | ( | int | notificationName | ) | [virtual] |
Remove a previously registered ICommand
to INotification
mapping from the Controller.
notificationName | the name of the INotification to remove the ICommand mapping for |
Implements PureMVC::IFacade.
void Facade::removeCore | ( | std::string | key | ) | [static] |
Remove a Core.
Remove the Model, View, Controller and Facade instances for the given key.
multitonKey | of the Core to remove |
IMediator * Facade::removeMediator | ( | std::string | mediatorName | ) | [virtual] |
IProxy * Facade::removeProxy | ( | std::string | proxyName | ) | [virtual] |
IMediator * Facade::retrieveMediator | ( | std::string | mediatorName | ) | [virtual] |
Retrieve an IMediator
from the View
.
mediatorName |
IMediator
previously registered with the given mediatorName
. Implements PureMVC::IFacade.
IProxy * Facade::retrieveProxy | ( | std::string | proxyName | ) | [virtual] |
Retrieve an IProxy
from the Model
by name.
proxyName | the name of the proxy to be retrieved. |
IProxy
instance previously registered with the given proxyName
. Implements PureMVC::IFacade.
void Facade::sendNotification | ( | int | notificationName | ) | [virtual] |
Send a INotification
.
Convenience method to prevent having to construct new notification instances in our implementation code.
notificationName | the name of the notification to send |
Implements PureMVC::INotifier.
void Facade::sendNotification | ( | int | notificationName, | |
int | notificationType | |||
) | [virtual] |
Send a INotification
.
Convenience method to prevent having to construct new notification instances in our implementation code.
notificationName | the name of the notification to send | |
type | the type of the notification (optional) |
Implements PureMVC::INotifier.
void Facade::sendNotification | ( | int | notificationName, | |
void * | body | |||
) | [virtual] |
Send a INotification
.
Convenience method to prevent having to construct new notification instances in our implementation code.
notificationName | the name of the notification to send | |
body | the body of the notification (optional) |
Implements PureMVC::INotifier.
void Facade::sendNotification | ( | int | notificationName, | |
void * | body, | |||
int | notificationType | |||
) | [virtual] |
Create and send an INotification
.
Keeps us from having to construct new notification instances in our implementation code.
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.
key | The name of the key |
Implements PureMVC::IMultitonKeyHeir.
virtual void PureMVC::IMultitonKeyHeir::setMultitonKey | ( | std::string | key | ) | [pure virtual, inherited] |
Set multiton key.
Sets the multiton key.
key | The name of the key |
Implemented in PureMVC::MultitonKeyHeir.