#include "AdeptHeaders.hpp"

#include "ComponentHeaders.hpp" 
#include "AttributeWatcher.hpp"
#include "EntityClassData.hpp"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Component::ClassData*
	Renderer::CreateFactoryRequest(
		const char* component_type,
		Component::FactoryRequestParameters *parameters,
		Entity::ClassData *class_data	
	)
{
	Check_Pointer(component_type);
	Check_Object(parameters);

	MemoryStream *component_stream = parameters->m_stream;
	Check_Object(component_stream);
	Channel::FactoryRequestParameters *channel_parameters =
		Cast_Pointer(Channel::FactoryRequestParameters*,parameters);

	if (!_stricmp(component_type, "AttributeWatcherOfInt"))
	{
		*component_stream << static_cast<int>(AttributeWatcherOfIntClassID);
		return
			AttributeWatcherOf<int, IntClassID>::CreateFactoryRequest(
				channel_parameters,
				class_data
			);
	}
	else if (!_stricmp(component_type, "MatcherOfInt"))
	{
		*component_stream << static_cast<int>(MatcherOfIntClassID);
		return MatcherOf<int>::CreateFactoryRequest(channel_parameters);
	}
	else
	{
		PAUSE((
			"%s: {[%s]Type=%s}: Bad Component type!",
			parameters->m_page->GetNotationFile()->GetFileName(),
			parameters->m_page->GetName(),
			component_type
		));
		return NULL;
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
	Renderer::CommandEncoder(const char* command_name)
{
	if (!_stricmp(command_name, "TranslationChanged"))
		return TranslationChangedCommandID;
	else if (!_stricmp(command_name, "RotationChanged"))
		return RotationChangedCommandID;
	else if (!_stricmp(command_name, "ScaleChanged"))
		return ScaleChangedCommandID;
	else if (!_stricmp(command_name, "ZScaleChanged"))
		return ZScaleChangedCommandID;
	else if (!_stricmp(command_name, "StartEffect"))
		return StartEffectCommandID;
	else if (!_stricmp(command_name, "StopEffect"))
		return StopEffectCommandID;
	else if (!_stricmp(command_name, "KillEffect"))
		return KillEffectCommandID;
	return -1;
}
