mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 20:50:38 +00:00
Add interface and abstract implementation of modelLoaderForData:
This commit is contained in:
parent
b5ecb4e490
commit
0d3c3d1b2a
2 changed files with 29 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
/** <title>NSBundleAdditions</title>
|
/** <title>GSModelLoaderFactory</title>
|
||||||
|
|
||||||
<abstract>Implementation of NSBundle Additions</abstract>
|
<abstract>Interface of GSModelLoader and GSModelLoaderFactory</abstract>
|
||||||
|
|
||||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
@class NSBundle;
|
@class NSBundle;
|
||||||
|
|
||||||
@interface GSModelLoader : NSObject
|
@interface GSModelLoader : NSObject
|
||||||
|
+ (BOOL) canReadData: (NSData *)theData;
|
||||||
+ (NSString *) type;
|
+ (NSString *) type;
|
||||||
+ (float) priority;
|
+ (float) priority;
|
||||||
- (BOOL) loadModelData: (NSData *)data
|
- (BOOL) loadModelData: (NSData *)data
|
||||||
|
@ -57,6 +58,7 @@
|
||||||
+ (NSString *) supportedModelFileAtPath: (NSString *)modelPath;
|
+ (NSString *) supportedModelFileAtPath: (NSString *)modelPath;
|
||||||
+ (GSModelLoader *) modelLoaderForFileType: (NSString *)type;
|
+ (GSModelLoader *) modelLoaderForFileType: (NSString *)type;
|
||||||
+ (GSModelLoader *) modelLoaderForFileName: (NSString *)modelPath;
|
+ (GSModelLoader *) modelLoaderForFileName: (NSString *)modelPath;
|
||||||
|
+ (GSModelLoader *) modelLoaderForData: (NSData *)theData;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
#import "GNUstepGUI/GSModelLoaderFactory.h"
|
#import "GNUstepGUI/GSModelLoaderFactory.h"
|
||||||
|
|
||||||
@implementation GSModelLoader
|
@implementation GSModelLoader
|
||||||
|
+ (BOOL) canReadData: (NSData *)theData
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSString *) type
|
+ (NSString *) type
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -103,6 +108,7 @@
|
||||||
static NSMutableDictionary *_modelMap = nil;
|
static NSMutableDictionary *_modelMap = nil;
|
||||||
|
|
||||||
@implementation GSModelLoaderFactory
|
@implementation GSModelLoaderFactory
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
NSArray *classes = GSObjCAllSubclassesOfClass([GSModelLoader class]);
|
NSArray *classes = GSObjCAllSubclassesOfClass([GSModelLoader class]);
|
||||||
|
@ -216,4 +222,23 @@ static NSMutableDictionary *_modelMap = nil;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (GSModelLoader *) modelLoaderForData: (NSData *)theData
|
||||||
|
{
|
||||||
|
NSEnumerator *oen = [_modelMap objectEnumerator];
|
||||||
|
Class aClass = nil;
|
||||||
|
GSModelLoader *result = nil;
|
||||||
|
|
||||||
|
while ((aClass = [oen nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if ([aClass canReadData: theData])
|
||||||
|
{
|
||||||
|
result = AUTORELEASE([[aClass alloc] init]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue