/* ClassAgent.m
 * Written By:  Thomas Burkholder
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 */

#import "ClassAgent.h"
#import "ClassAdditions.h"
#import <objc/objc-class.h>

@implementation ClassAgent

int descent(id son, id father)
{
	// Take care of private IB- and DB- kit classes
	if (!strncmp([son name],"IB",2))
		return 0;
	if (!strncmp([son name],"DB",2))
		return 0;
	if (strstr([son name],"_nib"))
		return 0;
	return 1;
}

- subdirectoryFor:anObject sender:sender
{
	static id list;

	if (!list) {
		list = [[SortedList alloc] init];
		[list setAgent:self];
	} else
		[list empty];
	[anObject subclasses:list allowPosers:NO filterWith:descent];

	return list;
}

- (BOOL)isLeaf:anObject sender:sender
{
	return (0==[anObject subclasses:nil allowPosers:NO filterWith:descent]);
}

- (const char *)displayStringFor:anObject sender:sender
{
	return [anObject name];
}

- (int)compare:first with:second sender:sender
{
	return strcmp([first name],[second name]);
}

- (const char *)titleOfColumn:(int)col
{
	return NULL;
}
@end