mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
New implementation based on GNU Notification. This version is much
faster, and has some better features. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1049 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
67aae38b85
commit
8471dd2b25
1 changed files with 13 additions and 126 deletions
|
@ -1,11 +1,9 @@
|
||||||
/* Implementation for NSNotification for GNUStep
|
/* Implementation of NSNotification for GNUstep
|
||||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||||
|
Created: March 1996
|
||||||
|
|
||||||
Written by: Georg Tuparev, EMBL, Academia Naturalis, & NIT,
|
|
||||||
Heidelberg, Germany
|
|
||||||
Tuparev@EMBL-Heidelberg.de
|
|
||||||
Last update: 11-feb-1996
|
|
||||||
|
|
||||||
This file is part of the GNU Objective C Class Library.
|
This file is part of the GNU Objective C Class Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
|
@ -17,134 +15,23 @@
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with this library; if not, write to the Free
|
License along with this library; if not, write to the Free
|
||||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* File Name : NSNotification.m
|
|
||||||
* Version : 0.6 beta
|
|
||||||
* Date : 11-feb-1996
|
|
||||||
*************************************************************************
|
|
||||||
* Notes :
|
|
||||||
* - The NeXT/OpenStep specification is not very clear if the objects has
|
|
||||||
* to be instances of a private class and/or the ivars should be private.
|
|
||||||
* Because it is supposed to inherit from NSNotification class, I decided
|
|
||||||
* not to use a private class or ivars. This is because in my own project
|
|
||||||
* I have seen, that if I use a lot of notifications, it is faster to
|
|
||||||
* access the ivears directly from a subclass. This is of course a
|
|
||||||
* philosophical question and I would like to get some feedback.
|
|
||||||
* To Do :
|
|
||||||
* Bugs :
|
|
||||||
* Last update: 11-feb-1996
|
|
||||||
* History : 17-jul-1995 - Birth;
|
|
||||||
* 26-aug-1995 - v.0.5 beta - tested on: (NS - extensively)
|
|
||||||
* Sun (SunOS, Solaris - compiling only);
|
|
||||||
* 11-feb-1996 - v.0.6 beta The current implementation allows
|
|
||||||
* to create a notification with nil name;
|
|
||||||
*************************************************************************
|
|
||||||
* Acknowledgments:
|
|
||||||
* - A part of the copyWithZone method is originally written by
|
|
||||||
* Jeremy Bettis <jeremy@hksys.com>
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#include <Foundation/NSDictionary.h>
|
|
||||||
#include <Foundation/NSString.h>
|
|
||||||
|
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include <objects/Notification.h>
|
||||||
|
|
||||||
@implementation NSNotification
|
@implementation NSNotification
|
||||||
|
|
||||||
/*************************************************************************
|
/* This class is fully implemented in GNU's Notification. */
|
||||||
*** init... and dealloc
|
|
||||||
*************************************************************************/
|
+ (void) initialize
|
||||||
- initWithName:(NSString *)aName object:(id)anObject
|
|
||||||
userInfo:(NSDictionary *)userInfo
|
|
||||||
/* The designated initalizer */
|
|
||||||
{
|
{
|
||||||
[super init];
|
if (self == [NSNotification class])
|
||||||
|
class_add_behavior (self, [Notification class]);
|
||||||
notificationName = [aName retain];
|
|
||||||
notificationObject = [anObject retain];
|
|
||||||
notificationInfo = [userInfo retain];
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-init
|
|
||||||
{
|
|
||||||
return [self initWithName:nil object:nil userInfo:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dealloc
|
|
||||||
{
|
|
||||||
[notificationName release];
|
|
||||||
[notificationObject release];
|
|
||||||
[notificationInfo release];
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
*** Creating Notification Objects
|
|
||||||
*************************************************************************/
|
|
||||||
+ (NSNotification *)notificationWithName:(NSString *)aName
|
|
||||||
object:(id)anObject
|
|
||||||
{
|
|
||||||
return [[[self alloc] initWithName:aName object:anObject
|
|
||||||
userInfo:nil] autorelease];
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSNotification *)notificationWithName:(NSString *)aName
|
|
||||||
object:(id)anObject userInfo:(NSDictionary *)userInfo
|
|
||||||
{
|
|
||||||
return [[[self alloc] initWithName:aName object:anObject
|
|
||||||
userInfo:userInfo] autorelease];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
*** Querying a Notification Object
|
|
||||||
*************************************************************************/
|
|
||||||
- (NSString *)name
|
|
||||||
{
|
|
||||||
return notificationName;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id)object
|
|
||||||
{
|
|
||||||
return notificationObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSDictionary *)userInfo
|
|
||||||
{
|
|
||||||
return notificationInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
*** NSCopying protocol
|
|
||||||
*************************************************************************/
|
|
||||||
- (id)copyWithZone:(NSZone *)zone
|
|
||||||
{
|
|
||||||
// This was stolen by me from Jeremy Bettis <jeremy@hksys.com> ;-)
|
|
||||||
if (NSShouldRetainWithZone(self,zone)) {
|
|
||||||
return [self retain];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Because it is not known if the notificationObject supports the
|
|
||||||
// NSCopying protocol, I think the most correct behavior is just
|
|
||||||
// to retain it ... but this is a philosophical question ;-)
|
|
||||||
return [[[self class] allocWithZone:zone]
|
|
||||||
initWithName: [notificationName copyWithZone:zone]
|
|
||||||
object: [notificationObject retain]
|
|
||||||
userInfo: [notificationInfo copyWithZone:zone]];
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NeXT
|
|
||||||
// This is here only to avoid a nasty warning :-(
|
|
||||||
- (id)copy
|
|
||||||
{
|
|
||||||
return [self copyWithZone:NSDefaultMallocZone()];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue