#include "munga.h"
#pragma hdrstop

#include "vdata.h"
#include "objstrm.h"

//#############################################################################
//#######################    RegisteredClass    ###############################
//#############################################################################

RegisteredClass::RegisteredClass(ClassID class_id)
{
	classID = class_id;
}

RegisteredClass::~RegisteredClass()
{
}

RegisteredClass::RegisteredClass(ObjectStream *stream)
{
   ObjectID object_ID;

	MemoryStream_Read(stream, &classID);
	Verify(classID != NullClassID);
	MemoryStream_Read(stream, &object_ID);
}

void RegisteredClass::BuildFromPage(ObjectStream *stream, NameList*, ClassID class_ID, ObjectID object_ID)
{
	*stream << class_ID << object_ID;
}

Logical RegisteredClass::TestInstance() const
{
	return true;
}

//
//#############################################################################
// GetClassID
//#############################################################################
//
RegisteredClass::ClassID RegisteredClass::GetClassID(const CString &class_name_string)
{
	//
	//--------------------------------------------------------------------------
	// HACK - Class name lookup could be perfromed via registration, for now,
	// use if statements
	//--------------------------------------------------------------------------
	//
	#define COMPARE_AND_RETURN(class_name)	if (!strcmp(class_name_string, #class_name)) return class_name##ClassID;

	COMPARE_AND_RETURN(AudioStateTrigger);
	COMPARE_AND_RETURN(AudioMotionScale);
	COMPARE_AND_RETURN(AudioRenderer);
	COMPARE_AND_RETURN(AudioLocation);
	COMPARE_AND_RETURN(AudioMotionTrigger);
	COMPARE_AND_RETURN(AudioControlMixer);
	COMPARE_AND_RETURN(AudioHingeScale);
	COMPARE_AND_RETURN(AudioControlSmoother);
	COMPARE_AND_RETURN(AudioResourceSelector);
	COMPARE_AND_RETURN(L4AudioCollisionTrigger);
	COMPARE_AND_RETURN(AudioResourceIndex);
	COMPARE_AND_RETURN(AudioScalarScale);
	COMPARE_AND_RETURN(AudioControlSend);
	COMPARE_AND_RETURN(L4AudioLocation);
	COMPARE_AND_RETURN(DirectPatchSource);
	COMPARE_AND_RETURN(Dynamic3DPatchSource);
	COMPARE_AND_RETURN(PatchResource);
	COMPARE_AND_RETURN(Static3DPatchSource);
	COMPARE_AND_RETURN(AudioControlMultiplier);
	COMPARE_AND_RETURN(AudioSampleAndHold);
	COMPARE_AND_RETURN(AudioScalarTrigger);
	COMPARE_AND_RETURN(AudioEnumerationTrigger);
	COMPARE_AND_RETURN(AudioIntegerTrigger);
	COMPARE_AND_RETURN(AudioLogicalTrigger);
	COMPARE_AND_RETURN(AudioControlsButtonTrigger);
	COMPARE_AND_RETURN(ExplosionResourceTable);
	COMPARE_AND_RETURN(AudioIdleWatcher);
	COMPARE_AND_RETURN(AudioControlEvent);
	COMPARE_AND_RETURN(AudioControlSequence);
	COMPARE_AND_RETURN(AudioControlSplitter);
	COMPARE_AND_RETURN(AudioLFO);
	COMPARE_AND_RETURN(AudioEnumerationDeltaTrigger);
	COMPARE_AND_RETURN(AudioScalarDeltaTrigger);
	COMPARE_AND_RETURN(AudioLevelOfDetail);
	COMPARE_AND_RETURN(PatchLevelOfDetail);
	COMPARE_AND_RETURN(AudioMessageWatcher);
	COMPARE_AND_RETURN(AudioControlsButtonMessageWatcher);

	//
	// Etc...
	//

	return NullClassID;
}
