appjam 0.1.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.rdoc +27 -0
  3. data/bin/appjam +17 -0
  4. data/lib/appjam.rb +50 -0
  5. data/lib/appjam/generators/Classes/ContactsAppDelegate.h.tt +18 -0
  6. data/lib/appjam/generators/Classes/ContactsAppDelegate.m.tt +88 -0
  7. data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Controller.h +54 -0
  8. data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Controller.m +145 -0
  9. data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Model.h +47 -0
  10. data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/Model.m +117 -0
  11. data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/View.h +39 -0
  12. data/lib/appjam/generators/Classes/org/puremvc/objectivec/core/View.m +207 -0
  13. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/ICommand.h +16 -0
  14. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IController.h +57 -0
  15. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IFacade.h +135 -0
  16. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IMediator.h +84 -0
  17. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IModel.h +50 -0
  18. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/INotification.h +57 -0
  19. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/INotifier.h +41 -0
  20. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IObserver.h +67 -0
  21. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IProxy.h +53 -0
  22. data/lib/appjam/generators/Classes/org/puremvc/objectivec/interfaces/IView.h +96 -0
  23. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/MacroCommand.h +50 -0
  24. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/MacroCommand.m +101 -0
  25. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/SimpleCommand.h +28 -0
  26. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/command/SimpleCommand.m +34 -0
  27. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/facade/Facade.h +52 -0
  28. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/facade/Facade.m +304 -0
  29. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/mediator/Mediator.h +35 -0
  30. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/mediator/Mediator.m +101 -0
  31. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notification.h +52 -0
  32. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notification.m +71 -0
  33. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notifier.h +40 -0
  34. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Notifier.m +54 -0
  35. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Observer.h +42 -0
  36. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/observer/Observer.m +67 -0
  37. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/proxy/Proxy.h +51 -0
  38. data/lib/appjam/generators/Classes/org/puremvc/objectivec/patterns/proxy/Proxy.m +73 -0
  39. data/lib/appjam/generators/Classes/users/ApplicationFacade.h.tt +31 -0
  40. data/lib/appjam/generators/Classes/users/ApplicationFacade.m.tt +33 -0
  41. data/lib/appjam/generators/Classes/users/controller/CreateUserCommand.h.tt +16 -0
  42. data/lib/appjam/generators/Classes/users/controller/CreateUserCommand.m.tt +27 -0
  43. data/lib/appjam/generators/Classes/users/controller/DeleteUserCommand.h.tt +16 -0
  44. data/lib/appjam/generators/Classes/users/controller/DeleteUserCommand.m.tt +21 -0
  45. data/lib/appjam/generators/Classes/users/controller/GetUsersCommand.h.tt +17 -0
  46. data/lib/appjam/generators/Classes/users/controller/GetUsersCommand.m.tt +21 -0
  47. data/lib/appjam/generators/Classes/users/controller/StartupCommand.h.tt +16 -0
  48. data/lib/appjam/generators/Classes/users/controller/StartupCommand.m.tt +29 -0
  49. data/lib/appjam/generators/Classes/users/controller/UpdateUserCommand.h.tt +16 -0
  50. data/lib/appjam/generators/Classes/users/controller/UpdateUserCommand.m.tt +27 -0
  51. data/lib/appjam/generators/Classes/users/model/UserProxy.h.tt +19 -0
  52. data/lib/appjam/generators/Classes/users/model/UserProxy.m.tt +59 -0
  53. data/lib/appjam/generators/Classes/users/model/vo/UserVO.h.tt +22 -0
  54. data/lib/appjam/generators/Classes/users/model/vo/UserVO.m.tt +47 -0
  55. data/lib/appjam/generators/Classes/users/view/ContactsMediator.h.tt +15 -0
  56. data/lib/appjam/generators/Classes/users/view/ContactsMediator.m.tt +43 -0
  57. data/lib/appjam/generators/Classes/users/view/UserFormMediator.h.tt +17 -0
  58. data/lib/appjam/generators/Classes/users/view/UserFormMediator.m.tt +57 -0
  59. data/lib/appjam/generators/Classes/users/view/UserListMediator.h.tt +17 -0
  60. data/lib/appjam/generators/Classes/users/view/UserListMediator.m.tt +59 -0
  61. data/lib/appjam/generators/Classes/users/view/components/Contacts.h.tt +27 -0
  62. data/lib/appjam/generators/Classes/users/view/components/Contacts.m.tt +46 -0
  63. data/lib/appjam/generators/Classes/users/view/components/UserForm.h.tt +37 -0
  64. data/lib/appjam/generators/Classes/users/view/components/UserForm.m.tt +118 -0
  65. data/lib/appjam/generators/Classes/users/view/components/UserList.h.tt +31 -0
  66. data/lib/appjam/generators/Classes/users/view/components/UserList.m.tt +77 -0
  67. data/lib/appjam/generators/Contacts-Info.plist.tt +28 -0
  68. data/lib/appjam/generators/Contacts.xcodeproj/eiffel.pbxuser +1671 -0
  69. data/lib/appjam/generators/Contacts.xcodeproj/eiffel.perspectivev3 +1638 -0
  70. data/lib/appjam/generators/Contacts.xcodeproj/project.pbxproj +574 -0
  71. data/lib/appjam/generators/Contacts_Prefix.pch.tt +8 -0
  72. data/lib/appjam/generators/app.rb +78 -0
  73. data/lib/appjam/generators/main.m.tt +17 -0
  74. data/lib/appjam/generators/utils/NSStringWhiteSpace.h +17 -0
  75. data/lib/appjam/generators/utils/NSStringWhiteSpace.m +31 -0
  76. data/lib/appjam/generators/utils/UIDevice.h +17 -0
  77. data/lib/appjam/generators/utils/UIDevice.m +83 -0
  78. data/lib/appjam/generators/utils/URLEncodeString.h +16 -0
  79. data/lib/appjam/generators/utils/URLEncodeString.m +29 -0
  80. data/lib/appjam/version.rb +10 -0
  81. data/spec/appjam_spec.rb +7 -0
  82. data/spec/spec_helper.rb +12 -0
  83. metadata +270 -0
@@ -0,0 +1,117 @@
1
+ //
2
+ // Model.m
3
+ // PureMVC_ObjectiveC
4
+ //
5
+ // PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
6
+ // PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
7
+ //
8
+
9
+ #import "Model.h"
10
+
11
+ static id<IModel> instance;
12
+
13
+ @implementation Model
14
+
15
+ @synthesize proxyMap;
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * <P>
21
+ * This <code>IModel</code> implementation is a Singleton,
22
+ * so you should not call the constructor
23
+ * directly, but instead call the static Singleton
24
+ * Factory method <code>[Model getInstance]</code>
25
+ *
26
+ * @throws NSException if Singleton instance has already been constructed
27
+ *
28
+ */
29
+ -(id)init {
30
+ if (instance != nil) {
31
+ [NSException raise:@"Model Singleton already constructed! Use getInstance instead." format:@""];
32
+ } else if (self = [super init]) {
33
+ self.proxyMap = [NSMutableDictionary dictionary];
34
+ [self initializeModel];
35
+ }
36
+ return self;
37
+ }
38
+
39
+ /**
40
+ * Initialize the Singleton <code>Model</code> instance.
41
+ *
42
+ * <P>
43
+ * Called automatically by the constructor, this
44
+ * is your opportunity to initialize the Singleton
45
+ * instance in your subclass without overriding the
46
+ * constructor.</P>
47
+ *
48
+ * @return void
49
+ */
50
+ -(void)initializeModel {
51
+ }
52
+
53
+ /**
54
+ * <code>Model</code> Singleton Factory method.
55
+ *
56
+ * @return the Singleton instance
57
+ */
58
+ +(id<IModel>)getInstance {
59
+ if (instance == nil) {
60
+ instance = [[self alloc] init];
61
+ }
62
+ return instance;
63
+ }
64
+
65
+ /**
66
+ * Check if a Proxy is registered
67
+ *
68
+ * @param proxyName
69
+ * @return whether a Proxy is currently registered with the given <code>proxyName</code>.
70
+ */
71
+ -(BOOL)hasProxy:(NSString *)proxyName {
72
+ return [proxyMap objectForKey:proxyName] != nil;
73
+ }
74
+
75
+ /**
76
+ * Register an <code>IProxy</code> with the <code>Model</code>.
77
+ *
78
+ * @param proxy an <code>IProxy</code> to be held by the <code>Model</code>.
79
+ */
80
+ -(void)registerProxy:(id<IProxy>)proxy {
81
+ [proxyMap setObject:proxy forKey:[proxy proxyName]];
82
+ [proxy onRegister];
83
+ }
84
+
85
+ /**
86
+ * Remove an <code>IProxy</code> from the <code>Model</code>.
87
+ *
88
+ * @param proxyName name of the <code>IProxy</code> instance to be removed.
89
+ * @return the <code>IProxy</code> that was removed from the <code>Model</code>
90
+ */
91
+ -(id<IProxy>)removeProxy:(NSString *)proxyName {
92
+ id<IProxy> proxy = [proxyMap objectForKey:proxyName];
93
+ if (proxy != nil) {
94
+ [proxy onRemove];
95
+ [proxyMap removeObjectForKey:proxyName];
96
+ }
97
+ return proxy;
98
+ }
99
+
100
+ /**
101
+ * Retrieve an <code>IProxy</code> from the <code>Model</code>.
102
+ *
103
+ * @param proxyName
104
+ * @return the <code>IProxy</code> instance previously registered with the given <code>proxyName</code>.
105
+ */
106
+ -(id<IProxy>)retrieveProxy:(NSString *)proxyName {
107
+ return [proxyMap objectForKey:proxyName];
108
+ }
109
+
110
+ -(void)dealloc {
111
+ self.proxyMap = nil;
112
+ [(id)instance release];
113
+ instance = nil;
114
+ [super dealloc];
115
+ }
116
+
117
+ @end
@@ -0,0 +1,39 @@
1
+ //
2
+ // View.h
3
+ // PureMVC_ObjectiveC
4
+ //
5
+ // PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
6
+ // PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import "IView.h"
11
+
12
+ /**
13
+ * A Singleton <code>IView</code> implementation.
14
+ *
15
+ * <P>
16
+ * In PureMVC, the <code>View</code> class assumes these responsibilities:
17
+ * <UL>
18
+ * <LI>Maintain a cache of <code>IMediator</code> instances.</LI>
19
+ * <LI>Provide methods for registering, retrieving, and removing <code>IMediators</code>.</LI>
20
+ * <LI>Notifiying <code>IMediators</code> when they are registered or removed.</LI>
21
+ * <LI>Managing the observer lists for each <code>INotification</code> in the application.</LI>
22
+ * <LI>Providing a method for attaching <code>IObservers</code> to an <code>INotification</code>'s observer list.</LI>
23
+ * <LI>Providing a method for broadcasting an <code>INotification</code>.</LI>
24
+ * <LI>Notifying the <code>IObservers</code> of a given <code>INotification</code> when it broadcast.</LI>
25
+ * </UL>
26
+ *
27
+ * @see Mediator, Observer, Notification
28
+ */
29
+ @interface View : NSObject <IView> {
30
+ NSMutableDictionary *mediatorMap, *observerMap;
31
+ }
32
+
33
+ @property(nonatomic, retain) NSMutableDictionary *mediatorMap, *observerMap;
34
+
35
+ -(id)init;
36
+ -(void)initializeView;
37
+ +(id<IView>)getInstance;
38
+
39
+ @end
@@ -0,0 +1,207 @@
1
+ //
2
+ // View.m
3
+ // PureMVC_ObjectiveC
4
+ //
5
+ // PureMVC Port to ObjectiveC by Brian Knorr <brian.knorr@puremvc.org>
6
+ // PureMVC - Copyright(c) 2006-2008 Futurescale, Inc., Some rights reserved.
7
+ //
8
+
9
+ #import "View.h"
10
+ #import "Observer.h"
11
+ #import "IObserver.h"
12
+
13
+ static id<IView> instance;
14
+
15
+ @implementation View
16
+
17
+ @synthesize mediatorMap, observerMap;
18
+
19
+ /**
20
+ * Constructor.
21
+ *
22
+ * <P>
23
+ * This <code>IView</code> implementation is a Singleton,
24
+ * so you should not call the constructor
25
+ * directly, but instead call the static Singleton
26
+ * Factory method <code>[View getInstance]</code>
27
+ *
28
+ * @throws NSException if Singleton instance has already been constructed
29
+ *
30
+ */
31
+ -(id)init {
32
+ if (instance != nil) {
33
+ [NSException raise:@"View Singleton already constructed! Use getInstance instead." format:@""];
34
+ } else if (self = [super init]) {
35
+ self.mediatorMap = [NSMutableDictionary dictionary];
36
+ self.observerMap = [NSMutableDictionary dictionary];
37
+ [self initializeView];
38
+ }
39
+ return self;
40
+ }
41
+
42
+ /**
43
+ * Initialize the Singleton View instance.
44
+ *
45
+ * <P>
46
+ * Called automatically by the constructor, this
47
+ * is your opportunity to initialize the Singleton
48
+ * instance in your subclass without overriding the
49
+ * constructor.</P>
50
+ *
51
+ * @return void
52
+ */
53
+ -(void)initializeView {
54
+ }
55
+
56
+ /**
57
+ * View Singleton Factory method.
58
+ *
59
+ * @return the Singleton instance of <code>View</code>
60
+ */
61
+ +(id<IView>)getInstance {
62
+ if (instance == nil) {
63
+ instance = [[self alloc] init];
64
+ }
65
+ return instance;
66
+ }
67
+
68
+ /**
69
+ * Check if a Mediator is registered or not
70
+ *
71
+ * @param mediatorName
72
+ * @return whether a Mediator is registered with the given <code>mediatorName</code>.
73
+ */
74
+ -(BOOL)hasMediator:(NSString *)mediatorName {
75
+ return [mediatorMap objectForKey:mediatorName] != nil;
76
+ }
77
+
78
+ /**
79
+ * Notify the <code>IObservers</code> for a particular <code>INotification</code>.
80
+ *
81
+ * <P>
82
+ * All previously attached <code>IObservers</code> for this <code>INotification</code>'s
83
+ * list are notified and are passed a reference to the <code>INotification</code> in
84
+ * the order in which they were registered.</P>
85
+ *
86
+ * @param notification the <code>INotification</code> to notify <code>IObservers</code> of.
87
+ */
88
+ -(void)notifyObservers:(id<INotification>)notification {
89
+ NSMutableArray *observers = [observerMap objectForKey:[notification name]];
90
+ NSMutableArray *workingObservers = [NSMutableArray array];
91
+ if (observers != nil) {
92
+ for (id<IObserver> observer in observers) {
93
+ [workingObservers addObject:observer];
94
+ }
95
+ for (id<IObserver> observer in workingObservers) {
96
+ [observer notifyObserver:notification];
97
+ }
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Register an <code>IMediator</code> instance with the <code>View</code>.
103
+ *
104
+ * <P>
105
+ * Registers the <code>IMediator</code> so that it can be retrieved by name,
106
+ * and further interrogates the <code>IMediator</code> for its
107
+ * <code>INotification</code> interests.</P>
108
+ * <P>
109
+ * If the <code>IMediator</code> returns any <code>INotification</code>
110
+ * names to be notified about, an <code>Observer</code> is created encapsulating
111
+ * the <code>IMediator</code> instance's <code>handleNotification</code> method
112
+ * and registering it as an <code>Observer</code> for all <code>INotifications</code> the
113
+ * <code>IMediator</code> is interested in.</p>
114
+ *
115
+ * @param mediator a reference to the <code>IMediator</code> instance
116
+ */
117
+ -(void)registerMediator:(id<IMediator>)mediator {
118
+ if ([mediatorMap objectForKey:[mediator mediatorName]] != nil) {
119
+ return;
120
+ }
121
+ [mediatorMap setObject:mediator forKey:[mediator mediatorName]];
122
+ NSArray *interests = [mediator listNotificationInterests];
123
+ if ([interests count] > 0) {
124
+ id<IObserver> observer = [Observer withNotifyMethod:@selector(handleNotification:) notifyContext:mediator];
125
+ for (NSString *notificationName in interests) {
126
+ [self registerObserver:notificationName observer:observer];
127
+ }
128
+ }
129
+ [mediator onRegister];
130
+ }
131
+
132
+ /**
133
+ * Register an <code>IObserver</code> to be notified
134
+ * of <code>INotifications</code> with a given name.
135
+ *
136
+ * @param notificationName the name of the <code>INotifications</code> to notify this <code>IObserver</code> of
137
+ * @param observer the <code>IObserver</code> to register
138
+ */
139
+ -(void)registerObserver:(NSString *)notificationName observer:(id<IObserver>)observer {
140
+ NSMutableArray *observers = [observerMap objectForKey:notificationName];
141
+ if (observers == nil) {
142
+ observers = [NSMutableArray array];
143
+ [observerMap setObject:observers forKey:notificationName];
144
+ }
145
+ [observers addObject:observer];
146
+ }
147
+
148
+ /**
149
+ * Remove an <code>IMediator</code> from the <code>View</code>.
150
+ *
151
+ * @param mediatorName name of the <code>IMediator</code> instance to be removed.
152
+ * @return the <code>IMediator</code> that was removed from the <code>View</code>
153
+ */
154
+ -(id<IMediator>)removeMediator:(NSString *)mediatorName {
155
+ id<IMediator> mediator = [mediatorMap objectForKey:mediatorName];
156
+ if (mediator != nil) {
157
+ NSArray *interests = [mediator listNotificationInterests];
158
+ for (NSString *notificationName in interests) {
159
+ [self removeObserver:notificationName notifyContext:mediator];
160
+ }
161
+ [mediator onRemove];
162
+ [mediator setViewComponent:nil];
163
+ [mediatorMap removeObjectForKey:mediatorName];
164
+ }
165
+ return mediator;
166
+ }
167
+
168
+ /**
169
+ * Remove the observer for a given notifyContext from an observer list for a given Notification name.
170
+ * <P>
171
+ * @param notificationName which observer list to remove from
172
+ * @param notifyContext remove the observer with this object as its notifyContext
173
+ */
174
+ -(void)removeObserver:(NSString *)notificationName notifyContext:(id)notifyContext {
175
+ NSMutableArray *observers = [observerMap objectForKey:notificationName];
176
+ if (observers != nil) {
177
+ for (id<IObserver> observer in observers) {
178
+ if ([observer compareNotifyContext:notifyContext]) {
179
+ [observers removeObject:observer];
180
+ break;
181
+ }
182
+ }
183
+ if ([observers count] == 0) {
184
+ [observerMap removeObjectForKey:notificationName];
185
+ }
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Retrieve an <code>IMediator</code> from the <code>View</code>.
191
+ *
192
+ * @param mediatorName the name of the <code>IMediator</code> instance to retrieve.
193
+ * @return the <code>IMediator</code> instance previously registered with the given <code>mediatorName</code>.
194
+ */
195
+ -(id<IMediator>)retrieveMediator:(NSString *)mediatorName {
196
+ return [mediatorMap objectForKey:mediatorName];
197
+ }
198
+
199
+ -(void)dealloc {
200
+ self.mediatorMap = nil;
201
+ self.observerMap = nil;
202
+ [(id)instance release];
203
+ instance = nil;
204
+ [super dealloc];
205
+ }
206
+
207
+ @end
@@ -0,0 +1,16 @@
1
+ #import "INotification.h"
2
+ /**
3
+ * The interface definition for a PureMVC Command.
4
+ *
5
+ * @see INotification
6
+ */
7
+ @protocol ICommand
8
+
9
+ /**
10
+ * Execute the <code>ICommand</code>'s logic to handle a given <code>INotification</code>.
11
+ *
12
+ * @param notification an <code>INotification</code> to handle.
13
+ */
14
+ -(void)execute:(id<INotification>)notification;
15
+
16
+ @end
@@ -0,0 +1,57 @@
1
+ #import "INotification.h"
2
+ /**
3
+ * The interface definition for a PureMVC Controller.
4
+ *
5
+ * <P>
6
+ * In PureMVC, an <code>IController</code> implementor
7
+ * follows the 'Command and Controller' strategy, and
8
+ * assumes these responsibilities:
9
+ * <UL>
10
+ * <LI> Remembering which <code>ICommand</code>s
11
+ * are intended to handle which <code>INotifications</code>.</LI>
12
+ * <LI> Registering itself as an <code>IObserver</code> with
13
+ * the <code>View</code> for each <code>INotification</code>
14
+ * that it has an <code>ICommand</code> mapping for.</LI>
15
+ * <LI> Creating a new instance of the proper <code>ICommand</code>
16
+ * to handle a given <code>INotification</code> when notified by the <code>View</code>.</LI>
17
+ * <LI> Calling the <code>ICommand</code>'s <code>execute</code>
18
+ * method, passing in the <code>INotification</code>.</LI>
19
+ * </UL>
20
+ *
21
+ * @see INotification, ICommand
22
+ */
23
+ @protocol IController
24
+
25
+ /**
26
+ * Execute the <code>ICommand</code> previously registered as the
27
+ * handler for <code>INotification</code>s with the given notification name.
28
+ *
29
+ * @param notification the <code>INotification</code> to execute the associated <code>ICommand</code> for
30
+ */
31
+ -(void)executeCommand:(id<INotification>)notification;
32
+
33
+ /**
34
+ * Check if a Command is registered for a given Notification
35
+ *
36
+ * @param notificationName
37
+ * @return whether a Command is currently registered for the given <code>notificationName</code>.
38
+ */
39
+ -(BOOL)hasCommand:(NSString *)notificationName;
40
+
41
+ /**
42
+ * Register a particular <code>ICommand</code> class as the handler
43
+ * for a particular <code>INotification</code>.
44
+ *
45
+ * @param notificationName the name of the <code>INotification</code>
46
+ * @param commandClassRef the Class of the <code>ICommand</code>
47
+ */
48
+ -(void)registerCommand:(NSString *)notificationName commandClassRef:(Class)commandClassRef;
49
+
50
+ /**
51
+ * Remove a previously registered <code>ICommand</code> to <code>INotification</code> mapping.
52
+ *
53
+ * @param notificationName the name of the <code>INotification</code> to remove the <code>ICommand</code> mapping for
54
+ */
55
+ -(void)removeCommand:(NSString *)notificationName;
56
+
57
+ @end
@@ -0,0 +1,135 @@
1
+ #import "INotification.h"
2
+ #import "IMediator.h"
3
+ #import "IProxy.h"
4
+ /**
5
+ * The interface definition for a PureMVC Facade.
6
+ *
7
+ * <P>
8
+ * The Facade Pattern suggests providing a single
9
+ * class to act as a central point of communication
10
+ * for a subsystem. </P>
11
+ *
12
+ * <P>
13
+ * In PureMVC, the Facade acts as an interface between
14
+ * the core MVC actors (Model, View, Controller) and
15
+ * the rest of your application.</P>
16
+ *
17
+ * @see IModel, IView, IController, ICommand, INotification
18
+ */
19
+ @protocol IFacade
20
+
21
+ /**
22
+ * Check if a Command is registered for a given Notification
23
+ *
24
+ * @param notificationName
25
+ * @return whether a Command is currently registered for the given <code>notificationName</code>.
26
+ */
27
+ -(BOOL)hasCommand:(NSString *)notificationName;
28
+
29
+ /**
30
+ * Check if a Mediator is registered or not
31
+ *
32
+ * @param mediatorName
33
+ * @return whether a Mediator is registered with the given <code>mediatorName</code>.
34
+ */
35
+ -(BOOL)hasMediator:(NSString *)mediatorName;
36
+
37
+ /**
38
+ * Check if a Proxy is registered
39
+ *
40
+ * @param proxyName
41
+ * @return whether a Proxy is currently registered with the given <code>proxyName</code>.
42
+ */
43
+ -(BOOL)hasProxy:(NSString *)proxyName;
44
+
45
+ /**
46
+ * Notify the <code>IObservers</code> for a particular <code>INotification</code>.
47
+ *
48
+ * <P>
49
+ * All previously attached <code>IObservers</code> for this <code>INotification</code>'s
50
+ * list are notified and are passed a reference to the <code>INotification</code> in
51
+ * the order in which they were registered.</P>
52
+ * <P>
53
+ * NOTE: Use this method only if you are sending custom Notifications. Otherwise
54
+ * use the sendNotification method which does not require you to create the
55
+ * Notification instance.</P>
56
+ *
57
+ * @param notification the <code>INotification</code> to notify <code>IObservers</code> of.
58
+ */
59
+ -(void)notifyObservers:(id<INotification>)notification;
60
+
61
+ /**
62
+ * Register an <code>ICommand</code> with the <code>Controller</code>.
63
+ *
64
+ * @param notificationName the name of the <code>INotification</code> to associate the <code>ICommand</code> with.
65
+ * @param commandClassRef a reference to the <code>Class</code> of the <code>ICommand</code>.
66
+ */
67
+ -(void)registerCommand:(NSString *)notificationName commandClassRef:(Class)commandClassRef;
68
+
69
+ /**
70
+ * Register an <code>IMediator</code> instance with the <code>View</code>.
71
+ *
72
+ * @param mediator a reference to the <code>IMediator</code> instance
73
+ */
74
+ -(void)registerMediator:(id<IMediator>)mediator;
75
+
76
+ /**
77
+ * Register an <code>IProxy</code> instance with the <code>Model</code>.
78
+ *
79
+ * @param proxy the <code>IProxy</code> to be registered with the <code>Model</code>.
80
+ */
81
+ -(void)registerProxy:(id<IProxy>)proxy;
82
+
83
+ /**
84
+ * Remove a previously registered <code>ICommand</code> to <code>INotification</code> mapping from the Controller.
85
+ *
86
+ * @param notificationName the name of the <code>INotification</code> to remove the <code>ICommand</code> mapping for
87
+ */
88
+ -(void)removeCommand:(NSString *)notificationName;
89
+
90
+ /**
91
+ * Remove a <code>IMediator</code> instance from the <code>View</code>.
92
+ *
93
+ * @param mediatorName name of the <code>IMediator</code> instance to be removed.
94
+ * @return the <code>IMediator</code> instance previously registered with the given <code>mediatorName</code>.
95
+ */
96
+ -(id<IMediator>)removeMediator:(NSString *)mediatorName;
97
+
98
+ /**
99
+ * Remove an <code>IProxy</code> instance from the <code>Model</code> by name.
100
+ *
101
+ * @param proxyName the <code>IProxy</code> to remove from the <code>Model</code>.
102
+ * @return the <code>IProxy</code> that was removed from the <code>Model</code>
103
+ */
104
+ -(id<IProxy>)removeProxy:(NSString *)proxyName;
105
+
106
+ /**
107
+ * Retrieve an <code>IMediator</code> instance from the <code>View</code>.
108
+ *
109
+ * @param mediatorName the name of the <code>IMediator</code> instance to retrievve
110
+ * @return the <code>IMediator</code> previously registered with the given <code>mediatorName</code>.
111
+ */
112
+ -(id<IMediator>)retrieveMediator:(NSString *)mediatorName;
113
+
114
+ /**
115
+ * Retrieve a <code>IProxy</code> from the <code>Model</code> by name.
116
+ *
117
+ * @param proxyName the name of the <code>IProxy</code> instance to be retrieved.
118
+ * @return the <code>IProxy</code> previously regisetered by <code>proxyName</code> with the <code>Model</code>.
119
+ */
120
+ -(id<IProxy>)retrieveProxy:(NSString *)proxyName;
121
+
122
+ /**
123
+ * Create and send an <code>INotification</code>.
124
+ *
125
+ * @param notificationName the name of the notiification to send
126
+ * @param body the body of the notification
127
+ * @param type the type of the notification
128
+ */
129
+ -(void)sendNotification:(NSString *)notificationName body:(id)body type:(NSString *)type;
130
+ -(void)sendNotification:(NSString *)notificationName;
131
+ -(void)sendNotification:(NSString *)notificationName body:(id)body;
132
+ -(void)sendNotification:(NSString *)notificationName type:(NSString *)type;
133
+
134
+ @end
135
+