/** @file metatypes.h
 *  Stores user defined types for type checking
 *	@author Nick Beatty (nbeatty@ea.com)
 *
 *	EABaseTypes
 *	(c) 2011 Electronic Arts Inc. 
 */

#ifndef EABASETYPES_METATYPES_H_
#define EABASETYPES_METATYPES_H_

#include "EABaseTypes/string.h"
#include "EABaseTypes/autoref.h"

namespace EA { namespace Allocator { class ICoreAllocator; } }

namespace EA
{
	namespace Types
	{
		EABASETYPES_FORWARD_DECLARATION(class, Array)
		EABASETYPES_FORWARD_DECLARATION(class, BaseType)
		EABASETYPES_FORWARD_DECLARATION(class, Object)
		
		/*! @class	MetaTypes metatypes.h "EABaseTypes/metatypes.h"
		*	@brief	Stores user defined types for type checking
		*/
		class MetaTypes
		{
		public:
			
			MetaTypes();
			~MetaTypes();

			/*!
			*	Load meta type definitions
			*	@param[in]	dataArr An array of meta type definitions
			*/
			void Load(ArrayIn dataArr);

			/*!
			*	Unload all meta type definitions
			*/
			void Unload();

			/*!
			*	Is the passed in type a registered meta type
			*	@param[in]	type name of the type
			*	@return true if the type is registered, false otherwise
			*/
			bool IsMetaType(const char* type);

			/*!
			*	Does the provided data match the type definition
			*	@param[in]	data the data to check
			*	@param[in]	type the type to check against
			*	@param[out]	message	A string to write the error message into
			*	@return true if the type is registered and the data matches the definition, false otherwise
			*/
			bool CheckMetaType(BaseTypeIn data, const char* type, EA::RawString& message);

			/*!
			* Get the currently registered types
			* @return An object containing the current meta types definitions. May be NULL
			*/
			ConstObjectReturn GetTypes();

		private:

			ObjectRef	mTypes;
		};
	}
}

#endif //EABASETYPES_METATYPES_H_
