/*	MiscImageDecoderController.h

	Copyright 1996 Netsurfer Inc.

	This notice may not be removed from this source code.
	The use and distribution of this software is governed by the
	terms of the MiscKit license agreement.  Refer to the license
	document included with the MiscKit distribution for the terms.

	Author: <bbum@friday.com>
	Converted to OpenStep, September 1996, Uwe Hoffmann.
*/

#import <Foundation/Foundation.h>

@class MiscImageDecoder;

typedef enum {
	MiscDecoderSeverityUnknown = -1, 	// unknown severity
	MiscDecoderSeverityNotice, 		// warning or notification message
	MiscDecoderSeverityFailure,		// message documents failure in decoder
	MiscDecoderSeverityFatal		// decoder seriously broken
} MiscImageDecoderErrorSeverity;

@protocol MiscImageDecoderErrorDelegate
- (void)decoder:(MiscImageDecoder *)aDecoder
	spewMessage:(NSString *)errMsg
	withSeverity:(MiscImageDecoderErrorSeverity)aSeverity;
@end

@interface MiscImageDecoderController:NSObject <MiscImageDecoderErrorDelegate>
{
@private
	NSMutableDictionary *decoderClassByType; 			/*"decoder classes hashed by type"*/
	NSMutableDictionary *decoderByType; 				/*"decoders hashed by type"*/
	NSMutableArray	*decoderList; 					/*"list of all decoders"*/
	
	NSWindowDepth imageDepth; 					/*"target decoding depth"*/

	struct __SIDFlags {						
		unsigned char verboseMode:1;				
		unsigned char spewStderr:1;				
	} _SIDFlags;							

	BOOL lastImageCorrupt;
	id <MiscImageDecoderErrorDelegate> errorDelegate;		/*"Error Delegate"*/
}

/*"Allocating and initializing"*/
+ sharedInstance;
- init;

/*"Image Type Management"*/
- (NSArray *)imageUnfilteredFileTypes;
- (BOOL)canInitWithData:(NSData *)data;

/*"Decoder Management"*/
- (MiscImageDecoder *)decoderForType:(NSString *)imageType;
- (Class)decoderClassForType:(NSString *)imageType;
- (MiscImageDecoder *)decoderForData:(NSData *)data;
- (Class)decoderClassForData:(NSData *)data;
- (void)addDecoderClass:(Class)aClass;

/*"Decoding an Image"*/
- (NSBitmapImageRep *)decodeFromFile:(NSString *)filePath;
- (NSBitmapImageRep *)decodeFromFile:(NSString *)filePath withDecoder:(MiscImageDecoder *)aDecoder;
- (NSBitmapImageRep *)decodeFromData:(NSData *)data;
- (NSBitmapImageRep *)decodeFromData:(NSData *)data withDecoder:(MiscImageDecoder *)aDecoder;

/*"Configuration"*/
- (void)setImageDepth:(NSWindowDepth)aDepth;
- (NSWindowDepth)imageDepth;

/*"State Inspection"*/
- (BOOL)lastImageCorrupt;
- (NSArray *)decoderArray;
- (NSDictionary *)decoderByType;
- (NSDictionary *)decoderClassByType;
- (BOOL)verboseMode;
- (void)setVerboseMode:(BOOL)aFlag;

/*"Error Handling"*/
- (void)setSpewToNSLog:(BOOL)aFlag;
- (BOOL)spewToNSLog;
- (void)setErrorDelegate:(id <MiscImageDecoderErrorDelegate>)aDelegate;
- (id <MiscImageDecoderErrorDelegate>)errorDelegate;

@end
