mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 04:20: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
|
@ -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