comparison dstep/foundation/NSNotificationQueue.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
comparison
equal deleted inserted replaced
13:4f583f7e242e 14:89f3c3ef1fd2
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Aug 3, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.foundation.NSNotificationQueue;
8
9 import dstep.foundation.NSArray;
10 import dstep.foundation.NSNotification;
11 import dstep.foundation.NSNotificationCenter;
12 import dstep.foundation.NSObject;
13 import dstep.objc.bridge.Bridge;
14 import dstep.objc.objc : id;
15
16 alias NSUInteger NSPostingStyle;
17 alias NSUInteger NSNotificationCoalescing;
18
19 enum
20 {
21 NSPostWhenIdle = 1,
22 NSPostASAP = 2,
23 NSPostNow = 3
24 }
25
26 enum
27 {
28 NSNotificationNoCoalescing = 0,
29 NSNotificationCoalescingOnName = 1,
30 NSNotificationCoalescingOnSender = 2
31 }
32
33 class NSNotificationQueue : NSObject
34 {
35 mixin ObjcWrap;
36
37 static Object defaultQueue ()
38 {
39 return invokeObjcSelfClass!(Object, "defaultQueue");
40 }
41
42 Object initWithNotificationCenter (NSNotificationCenter notificationCenter)
43 {
44 return invokeObjcSelf!(Object, "initWithNotificationCenter:", NSNotificationCenter)(notificationCenter);
45 }
46
47 this (NSNotificationCenter notificationCenter)
48 {
49 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
50 id result = Bridge.invokeObjcMethod!(id, "initWithNotificationCenter:", NSNotificationCenter)(objcObject, notificationCenter);
51
52 if (result)
53 objcObject = ret;
54
55 dObject = this;
56 }
57
58 void enqueueNotification (NSNotification notification, uint postingStyle)
59 {
60 return invokeObjcSelf!(void, "enqueueNotification:postingStyle:", NSNotification, uint)(notification, postingStyle);
61 }
62
63 void enqueueNotification (NSNotification notification, uint postingStyle, NSUInteger coalesceMask, NSArray modes)
64 {
65 return invokeObjcSelf!(void, "enqueueNotification:postingStyle:coalesceMask:forModes:", NSNotification, uint, NSUInteger, NSArray)(notification, postingStyle, coalesceMask, modes);
66 }
67
68 void dequeueNotificationsMatching (NSNotification notification, NSUInteger coalesceMask)
69 {
70 return invokeObjcSelf!(void, "dequeueNotificationsMatching:coalesceMask:", NSNotification, NSUInteger)(notification, coalesceMask);
71 }
72 }
73