mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 21:00:37 +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.
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
|||
@class NSBundle;
|
||||
|
||||
@interface GSModelLoader : NSObject
|
||||
+ (BOOL) canReadData: (NSData *)theData;
|
||||
+ (NSString *) type;
|
||||
+ (float) priority;
|
||||
- (BOOL) loadModelData: (NSData *)data
|
||||
|
@ -57,6 +58,7 @@
|
|||
+ (NSString *) supportedModelFileAtPath: (NSString *)modelPath;
|
||||
+ (GSModelLoader *) modelLoaderForFileType: (NSString *)type;
|
||||
+ (GSModelLoader *) modelLoaderForFileName: (NSString *)modelPath;
|
||||
+ (GSModelLoader *) modelLoaderForData: (NSData *)theData;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
#import "GNUstepGUI/GSModelLoaderFactory.h"
|
||||
|
||||
@implementation GSModelLoader
|
||||
+ (BOOL) canReadData: (NSData *)theData
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (NSString *) type
|
||||
{
|
||||
return nil;
|
||||
|
@ -103,6 +108,7 @@
|
|||
static NSMutableDictionary *_modelMap = nil;
|
||||
|
||||
@implementation GSModelLoaderFactory
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
NSArray *classes = GSObjCAllSubclassesOfClass([GSModelLoader class]);
|
||||
|
@ -216,4 +222,23 @@ static NSMutableDictionary *_modelMap = nil;
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue