#pragma once

#include "MAXProxies.hpp"

namespace MAXProxies {

	class MAXPolygon;
	class MAXVertex;

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

		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors
	//
	public:
		static MAXIndex*
			MakeProxy(
				MAXPolygon *polygon,
				MAXVertex *vertex
			)
				{return new MAXIndex(polygon, vertex);}

		void
			Destroy();

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

	protected:
		MAXIndex(
			MAXPolygon *polygon,
			MAXVertex *index
		);
		~MAXIndex();

		static Stuff::MemoryBlock
			*AllocatedMemory;

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

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Vertex management functions
	//
	public:
		MAXPolygon*
			GetPolygonProxy()
				{
					Check_Object(this);
					return Cast_Pointer(MAXPolygon*, polygonProxy);
				}
		MAXVertex*
			GetVertexProxy()
				{
					Check_Object(this);
					return Cast_Pointer(MAXVertex*, vertexProxy);
				}

		Proxies::IndexProxy*
			UseNextIndexProxy();
		Proxies::IndexProxy*
			UsePreviousIndexProxy();
	};
}
