mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 01:21:08 +00:00
Implemented registry.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7547 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
36c1dc24c5
commit
5648d97c5a
2 changed files with 43 additions and 13 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2000-09-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSURLHandle.m: Implemented subclass registry.
|
||||||
|
|
||||||
2000-09-19 Fred Kiefer <FredKiefer@gmx.de>
|
2000-09-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/gnustep/base/Unicode.h:
|
* Headers/gnustep/base/Unicode.h:
|
||||||
|
|
|
@ -39,28 +39,54 @@ how it should work...
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@implementation NSURLHandle
|
@implementation NSURLHandle
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
static NSMutableArray *registry = nil;
|
||||||
+ (void) registerURLHandleClass: (Class)_urlHandleSubclass
|
|
||||||
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
//FIXME
|
if (self == [NSURLHandle class])
|
||||||
[self notImplemented: _cmd];
|
{
|
||||||
|
registry = [NSMutableArray new];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
+ (void) registerURLHandleClass: (Class)_urlHandleSubclass
|
||||||
+ (Class)URLHandleClassForURL: (NSURL*)_url
|
|
||||||
{
|
{
|
||||||
//FIXME
|
if ([registry indexOfObjectIdenticalTo: _urlHandleSubclass] != NSNotFound)
|
||||||
[self notImplemented: _cmd];
|
{
|
||||||
|
[registry addObject: _urlHandleSubclass];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (Class) URLHandleClassForURL: (NSURL*)_url
|
||||||
|
{
|
||||||
|
unsigned count = [registry count];
|
||||||
|
|
||||||
|
while (count-- > 0)
|
||||||
|
{
|
||||||
|
id found = [registry objectAtIndex: count];
|
||||||
|
|
||||||
|
if ([found canInitWithURL: _url] == YES)
|
||||||
|
{
|
||||||
|
return (Class)found;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
- (id) initWithURL: (NSURL*)_url
|
- (id) initWithURL: (NSURL*)_url
|
||||||
cached: (BOOL)_cached
|
cached: (BOOL)_cached
|
||||||
{
|
{
|
||||||
//FIXME
|
Class concreteSubclass = [NSURLHandle URLHandleClassForURL: _url];
|
||||||
[self notImplemented: _cmd];
|
NSURLHandle *instance;
|
||||||
return nil;
|
|
||||||
|
if (concreteSubclass == 0)
|
||||||
|
{
|
||||||
|
NSLog(@"Attempt to init NSURLHandle with unsupported URL schema");
|
||||||
|
RELEASE(self);
|
||||||
|
}
|
||||||
|
RELEASE(self);
|
||||||
|
instance = [concreteSubclass alloc];
|
||||||
|
return [instance initWithURL: _url cached: _cached];
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue