#pragma once

#include "Proxies.hpp"
#include "GenericProxy.hpp"

namespace Proxies {

	class PolygonProxy;

	//
	//#########################################################################
	//#####################    IndexProxy    ##########################
	//#########################################################################
	//
	class IndexProxy:
		public GenericProxy
	{
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors
	//
	protected:
		IndexProxy(
			ClassData *class_data,
			PolygonProxy *polygon,
			VertexProxy *index
		);
		IndexProxy(
			PolygonProxy *polygon,
			VertexProxy *index
		);
		~IndexProxy();

		static Stuff::MemoryBlock
			*AllocatedMemory;

	public:
		static IndexProxy*
			MakeProxy(
				PolygonProxy *polygon,
				VertexProxy *index
			)
				{return new IndexProxy(polygon, index);}
		void
			Destroy();

		void*
			operator new(size_t)
				{return AllocatedMemory->New();}
		void
			operator delete(void *where)
				{AllocatedMemory->Delete(where);}

	public:
		bool
			GetName(class Stuff::MString *name)
				{Check_Object(this); Check_Object(name); return false;}
		void
			SetName(const char* name)
				{Check_Object(this); Check_Pointer(name);}

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Testing
	//
	public:
		void
			TestInstance() const;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Vertex management functions
	//
	public:
		//
		// Copies the elements of a polygon into this polygon
		//
		PolygonProxy*
			GetPolygonProxy()
				{Check_Object(this); return polygonProxy;}
		VertexProxy*
			GetVertexProxy()
				{Check_Object(this); return vertexProxy;}

	protected:
		PolygonProxy
			*polygonProxy;
		VertexProxy
			*vertexProxy;
	};

}
