#pragma once
#define TEXTUREPOOL_HPP

#include "Compost.hpp"

namespace Compost
{

class TexturePool
{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors/Destructors
	//
	public:
		TexturePool();
		~TexturePool();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Image handling
	//
	public:
		int
			Add(
				Stuff::MString name,
				int width,
				int height,
				Feature_Texture::TextureMode type
			);
		int
			Add(
				int index,
				int width,
				int height,
				Feature_Texture::TextureMode type
			);

		Feature_Texture*
			Get(const char* imageName);
		Feature_Texture*
			Get(int index);
		int
			GetIndex(Feature_Texture*);

		bool
			Load(const char* , int=0);
		bool
			Load(int index , int=0);
		bool
			Load(Feature_Texture *);

		void
			Remove(Feature_Texture *image);
		void
			Remove(const char* name);
		void
			Remove(int index);


		void
			LoadIndex();
		void
			LoadIndex(const char*);
		void
			LoadIndex(Stuff::NotationFile*);
		bool
			SaveIndex(const char*);

		const char*
			GetTexturePath()
				{ Check_Pointer(this); return texturePath; }

		void
			SetTexturePath(const char *pName);

		void
			SetTexturePath(const char *pName, const char *tcf_filename);

		Stuff::TableOf<Feature_Texture*, int>*
			GetImageTable()
				{ return &imageTable; }

		static TexturePool *Instance;

		bool
			IsChanged()
				{ Check_Pointer(this); return changed; }
		
		void
			IsChanged(bool b)
				{ Check_Pointer(this); changed = b; }

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Testing
	//
	public:
		void
			TestInstance() const
				{}

	protected:
		int
			GetMask(int);

		char*
			texturePath;

		Stuff::TableOf<Feature_Texture*, int>
			imageTable;

		int fill[16];

		bool
			changed;
};

}