view dstep/foundation/NSDistributedNotificationCenter.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Aug 3, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.foundation.NSDistributedNotificationCenter;

import dstep.foundation.NSDictionary;
import dstep.foundation.NSNotification;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc : id;

import bindings = dstep.foundation.NSDistributedNotificationCenter_bindings;

alias NSUInteger NSNotificationSuspensionBehavior;

const NSString NSLocalNotificationCenterType;

enum
{
	NSNotificationSuspensionBehaviorDrop = 1,
	NSNotificationSuspensionBehaviorCoalesce = 2,
	NSNotificationSuspensionBehaviorHold = 3,
	NSNotificationSuspensionBehaviorDeliverImmediately = 4
}

enum
{
	NSNotificationDeliverImmediately = (1 << 0),
	NSNotificationPostToAllSessions = (1 << 1)
}

static this ()
{
	NSLocalNotificationCenterType = new NSString(bindings.NSLocalNotificationCenterType);
}

class NSDistributedNotificationCenter : NSNotificationCenter
{
	mixin ObjcWrap;

	static NSDistributedNotificationCenter notificationCenterForType (NSString notificationCenterType)
	{
		return invokeObjcSelfClass!(NSDistributedNotificationCenter, "notificationCenterForType:", NSString)(notificationCenterTypereturn result is this.objcObject ? this : (result !is null ? new NSDistributedNotificationCenter(result) : null);	}

	static Object defaultCenter ()
	{
		return invokeObjcSelfClass!(Object, "defaultCenter");
	}

	void addObserver (Object observer, SEL selector, NSString name, NSString object, uint suspensionBehavior)
	{
		return invokeObjcSelf!(void, "addObserver:selector:name:object:suspensionBehavior:", Object, SEL, NSString, NSString, uint)(observer, selector, name, object, suspensionBehavior);
	}

	void postNotificationName (NSString name, NSString object, NSDictionary userInfo, bool deliverImmediately)
	{
		return invokeObjcSelf!(void, "postNotificationName:object:userInfo:deliverImmediately:", NSString, NSString, NSDictionary, bool)(name, object, userInfo, deliverImmediately);
	}

	void postNotificationName (NSString name, NSString object, NSDictionary userInfo, NSUInteger options)
	{
		return invokeObjcSelf!(void, "postNotificationName:object:userInfo:options:", NSString, NSString, NSDictionary, NSUInteger)(name, object, userInfo, options);
	}

	void setSuspended (bool suspended)
	{
		return invokeObjcSelf!(void, "setSuspended:", bool)(suspended);
	}

	bool suspended ()
	{
		return invokeObjcSelf!(bool, "suspended");
	}

	void addObserver (Object observer, SEL aSelector, NSString aName, NSString anObject)
	{
		return invokeObjcSelf!(void, "addObserver:selector:name:object:", Object, SEL, NSString, NSString)(observer, aSelector, aName, anObject);
	}

	void postNotificationName (NSString aName, NSString anObject)
	{
		return invokeObjcSelf!(void, "postNotificationName:object:", NSString, NSString)(aName, anObject);
	}

	void postNotificationName (NSString aName, NSString anObject, NSDictionary aUserInfo)
	{
		return invokeObjcSelf!(void, "postNotificationName:object:userInfo:", NSString, NSString, NSDictionary)(aName, anObject, aUserInfo);
	}

	void removeObserver (Object observer, NSString aName, NSString anObject)
	{
		return invokeObjcSelf!(void, "removeObserver:name:object:", Object, NSString, NSString)(observer, aName, anObject);
	}
}