#pragma once

#include "Adept.hpp"
#include "VideoRenderer.hpp"
#include "VideoComponent.hpp"

namespace ElementRenderer {class LightElement;}

namespace Adept {

	class AttributeEntry;
	class Entity__ClassData;

	//#########################################################################
	//##########################  LightComponent  ##############################
	//#########################################################################
	//
	// When instantiating this class, the following methods must be explicitly
	// defined:
	//
	//   void InitializeClass();
	//   void ReadGeometryFromResource(...)
	//   LightComponent<C,G,B>* Make(...)
	//	  Derivation* CreateFactoryRequest(...)
	//
	// The methods having templates in this header file should work fine, but
	// explicitly define whatever you need.
	//

	class LightComponent:
		public VideoComponent
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();
		static ClassData
			*DefaultData;

		typedef VideoComponent BaseClass;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructor/Destructor
	//
	protected:
		LightComponent(
			ClassData *class_data,
			MemoryStream *stream,
			VideoComponentWeb *owning_web
		);

		static Element*
			AllocateLight();

		void
			SkipStreamData(MemoryStream *stream);

	public:
		static LightComponent*
			Create(
				MemoryStream *stream,
				VideoComponentWeb *owning_web
			);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Component support
	//
	public:
		ElementRenderer::LightElement*
			GetElement()
				{
					Check_Object(this);
					return
						Cast_Pointer(
							ElementRenderer::LightElement*,
							componentElement
						);
				}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Component execution
	//
	public:
		void
			ChannelChanged(Channel *channel);
		void
			Execute();

	protected:
		Entity
			*owningEntity;
		AttributeEntry
			*intensityAttribute;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Accessors
	//
	public:
		void
			TestInstance();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Tool-related Functions
	//
	public:
		static ClassData*
			CreateFactoryRequest(
				FactoryRequestParameters *parameters,
				Entity__ClassData *class_data
			);
	};

}
