ftp.nice.ch/pub/next/science/chemistry/BeakerBoy.0.31.s.tar.gz#/BeakerBoy.0.31.s/FileManager.subproj/BBFileFilterManager.m

This is BBFileFilterManager.m in view mode; [Download] [Up]

/* BBFileFilterManager.m				 
 *
 * This FilterManager is resposible for the conversion of the different
 * molFileFormats (ways of storing molData) into useful objects.
 * The real work (read/write) is done by single filters that are known here.
 *
 * For interface-info see the header file. The comments in this file mostly
 * cover only the real implementation details.
 *
 * Written by: 		Thomas Engel
 * Created:    		15.11.1993 (Copyleft)
 * Last modified: 	30.10.1994
 */

#import "BBFileFilterManager.h"
#import "BBLook3DFilter.h"
#import "BBPdbFilter.h"
#import "BBAlchemyFilter.h"
#import "BBMvtxFilter.h"
#import "BBMacMoleculeFilter.h"

@implementation BBFileFilterManager

- init
{
	self = [super init];
	if( !self ) return self;

	// Looks good. A are for real. Lets do the init.
	
	filterList = [List new];
	[self addFilter:[BBLook3DFilter new]];
	[self addFilter:[BBPdbFilter new]];
	[self addFilter:[BBAlchemyFilter new]];
	[self addFilter:[BBMvtxFilter new]];
	[self addFilter:[BBMacMoleculeFilter new]];
	
	return self;
}

- free
{
	[[filterList freeObjects] free];
	return self;
}

- readBeaker:aBeaker fromFile:(const char *)filename
{
	// Here we try to find the best filter available for this file.
	// If there is one that handles all the details we will pass this request
	// along. If there are more or the only available filter does not handle
	// all the details of the file we will inform him.
	
	id		theFilter;
	float	bestGrade;
	float	aGrade;
	int	i;
	
	theFilter = nil;
	bestGrade = 0;
	
	for( i=0; i<[filterList count]; i++ )
	{
		aGrade = [[filterList objectAt:i] canReadFile:filename];
		if( aGrade > bestGrade )
		{
			bestGrade = aGrade;
			theFilter = [filterList objectAt:i];
		}
	}
	
	if( theFilter == nil )
			NXRunAlertPanel( NULL, 
							 "There is no filter for this data in the "\
							 "current release", 
							 "Sorry", NULL, NULL );

	else	[theFilter readBeaker:aBeaker fromFile:filename];
	
	return self;
}

- addFilter:aFilter
{
	[filterList addObject:aFilter];
	return self;
}

- removeFilter:aFilter
{
	return self;
}

@end

/*
 * History: 30.10.94 Switched to the MiscString.
 *
 *			15.03.94 Added MvtxFilter and AlchemyFilter.
 *
 *			14.03.94 Made it a real manager. It now will handle different
 *					 filetypes.
 *
 *			14.01.94 Made the parsing somewhat nicer and cleaner.
 *
 *			13.01.94 Did completely rewrite the parsing section. Now uses
 *					 MOStrings to parse self.
 *
 *			28.12.93 Created a initBeaker method.
 *
 *
 * Notes: - Once we have some more filters that can only MAYBE handle a
 *			file we will have to bring up a panel that lets the user choose
 *			the filter he wants.
 *
 *
 * Bugs: - No removal of filters.
 *
 *		 - Because this object might someday be used by different beakers at
 *		   the same time I should add some locking or what ever. Right
 *		   this is no problem at all.

 */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.