#ifndef VEXIMAGEHANDLER
#define VEXIMAGEHANDLER

#include <map>
#include "VexImage.h"
#include <UT/UT_String.h>
#include "UT/UT_SpinLock.h"

/*
 * The Vex Image Handler can be used to store and retrieve images from disk,
 * It acts as a simple dispatcher that manages images in memory for VEX image queries
 */

class VexImageHandler
{
public: 
	VexImageHandler();
	~VexImageHandler();

	// Used to track VEX calls to the image handler
	int mRefCounter;
	
	// Returns an image based on the name specified
	VexImage* GetImage(const UT_String& inImageName);

	// Clears all the loaded images;
	void ClearImages();

private:

	// The lock used when getting an image
	UT_SpinLock mSpinLock;

	// Ms to close the lock
	static int sSpinLock;

	// The image bindings used for storing images
	std::map<UT_String, VexImage*> mImageBindings;

	// Finds an image in the bindings, returns NULL if not found
	VexImage* FindImage(const UT_String& inImageName);
};

#endif