
///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_Resource_System.h
// Author : Andy Tate
// Date   : 20-Jun-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __ASURA_RESOURCE_SYSTEM_H__
#define __ASURA_RESOURCE_SYSTEM_H__

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Core/Asura_HashTree.h"
#include "Core/Resources/Asura_ResourceBank.h"


////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

class Asura_ResourceSet_Base;


////////////////////////////////////////////////////////////////////////////////
// Global variables...
////////////////////////////////////////////////////////////////////////////////

static const u_int		uASURA_RESOURCE_BANK_TRG_PERMANENT		= ASURA_TEXTURE_LOADED_PERMANENT;
static const char*		szASURA_RESOURCE_BANK_NAME_PERMANENT	= "Permanent";
static Asura_Hash_ID	uASURA_RESOURCE_BANK_HASH_PERMANENT		= 0x27D854AE;	//Asura_GetHashID("Permanent"),


////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : Asura_Resource_System
// Author       : Andy Tate
// Date         : 20-Jun-2008
//
// Description  : Static class used to hold the current status of all resources
//				  and resource-banks used by Asura.
////////////////////////////////////////////////////////////////////////////////

class Asura_Resource_System
{
public:
	// Public functions...
	static void	Initialise(void);
	static void	Shutdown(void);

	// Resource-bank functions...
	static bool	CreateResourceBank(const Asura_Hash_ID uBankHash, const char* szBankName, const u_int uTextureResetGroup);
	static bool	DestroyResourceBank(const Asura_Hash_ID uBankHash);

	// Resource-set functions...
	static bool	AddResourceSet(Asura_ResourceSet_Base& xResourceSet);
    static bool RemoveResourceSet(Asura_ResourceSet_Base& xResourceSet);

	// Accessor functions...
	static bool				HasResourceBank(const Asura_Hash_ID uBankHash)	{ return((s_pxResourceBankContainer != NULL) && (s_pxResourceBankContainer->GetDataByHash(uBankHash) != NULL)); }
	static Asura_Hash_ID	GetCurrentResourceBank(void)					{ return(s_uCurrentResourceBank); }


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private typedefs...
	typedef Asura_TemplateHashTree<Asura_ResourceBank> ResourceBankContainer;
	typedef Asura_TemplateHashTree_Iterator<Asura_ResourceBank> ResourceBankIterator;
	typedef Asura_TemplateHashTree_ConstIterator<Asura_ResourceBank> ResourceBankConstIterator;

	typedef Asura_TemplateHashTree<Asura_ResourceSet_Base*> ResourceSetContainer;
	typedef Asura_TemplateHashTree_Iterator<Asura_ResourceSet_Base*> ResourceSetIterator;
	typedef Asura_TemplateHashTree_ConstIterator<Asura_ResourceSet_Base*> ResourceSetConstIterator;

	// Private variables...
	static Asura_Hash_ID			s_uCurrentResourceBank;		// Hash-ID of the bank to add resources to.
	static ResourceBankContainer*	s_pxResourceBankContainer;	// The data-container used for the bank used to store resources.
	static ResourceSetContainer*	s_pxResourceSetContainer;	// The data-container used for the set of resources of a particular type.

	// Private functions...
	Asura_Resource_System(void);
	Asura_Resource_System(const Asura_Resource_System& xOther);
	~Asura_Resource_System();

	Asura_Resource_System&	operator=(const Asura_Resource_System& xOther);

};   // End of class 'Asura_Resource_System'.


#endif   // ifndef __ASURA_RESOURCE_SYSTEM_H__


/// End of file. ///
