-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathHandlerFactory.m
80 lines (64 loc) · 2.2 KB
/
HandlerFactory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// HandlerFactory.m
// SimpleCap
//
// Created by - on 08/03/16.
// Copyright 2008 Hiroshi Hashiguchi. All rights reserved.
//
#import "HandlerFactory.h"
#import "WindowHandler.h"
#import "TrackWindowHandler.h"
#import "SelectionHandler.h"
#import "ScreenHandler.h"
#import "MenuHandler.h"
#import "ApplicationHandler.h"
#import "WidgetHandler.h"
#import "Handler.h"
@implementation HandlerFactory
- (id)initWithCaptureController:(CaptureController*)capture_controller
{
self = [super init];
if (self) {
_handlers = [[NSMutableDictionary alloc] init];
_capture_controller = [capture_controller retain];
}
return self;
}
- (void) dealloc
{
[_handlers release];
[_capture_controller release];
[super dealloc];
}
- (Handler*)handlerWithName:(NSString*)name
{
Handler* handler = (Handler*)[_handlers objectForKey:name];
if (!handler) {
if ([name isEqualToString:CAPTURE_WINDOW]) {
handler = [[WindowHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
} else if ([name isEqualToString:CAPTURE_TRACKWINDOW]) {
handler = [[TrackWindowHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
} else if ([name isEqualToString:CAPTURE_SELECTION]) {
handler = [[SelectionHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
} else if ([name isEqualToString:CAPTURE_SCREEN]) {
handler = [[ScreenHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
} else if ([name isEqualToString:CAPTURE_MENU]) {
handler = [[MenuHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
} else if ([name isEqualToString:CAPTURE_APPLICATION]) {
handler = [[ApplicationHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
} else if ([name isEqualToString:CAPTURE_WIDGET]) {
handler = [[WidgetHandler alloc] initWithCaptureController:_capture_controller];
[_handlers setObject:handler forKey:name];
}
[handler setup];
[handler release];
}
return handler;
}
@end