/*	MiscUtilities.m

	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.

	Version 1 (1 February 1995)
	    - MiscRequiresConcreteImplementation() and
		MiscRequiresConcreteObject()
		Copyright 1995 Christopher J. Kane
*/

#import <MiscUtilities.h>
#import <Foundation/Foundation.h>

void MiscRequiresConcreteImplementation(id self, SEL _cmd, Class abstractClass)
{
    NSString *selName;
    NSCParameterAssert(self != nil);
    NSCParameterAssert(_cmd != 0);
    selName = NSStringFromSelector(_cmd);
    if ([self class] == abstractClass)
	[NSException raise:NSInvalidArgumentException format:@"*** -%s cannot be sent to an abstract object of class %@: Create a concrete instance!", selName, NSStringFromClass(abstractClass)];
    [NSException raise:NSInvalidArgumentException format:@"*** -%s only defined for abstract class.  Define -[%@ %s]!", selName, NSStringFromClass([self class]), selName];
}

void MiscRequiresConcreteObject(id self, SEL _cmd)
{
    NSCParameterAssert(self != nil);
    NSCParameterAssert(_cmd != 0);
    [NSException raise:NSInvalidArgumentException format:@"*** initialization method -%s cannot be sent to an abstract object of class %@: Create a concrete instance!", NSStringFromSelector(_cmd), NSStringFromClass([self class])];
}
