/**
* FX Storage
* @version: 12-28-2004
* @author Joseph 'Pcjoe' Florencio
*/
#ifndef FXSTORAGE_H
#define FXSTORAGE_H

#define FXDATA_OPTION_S "option"
#define FXDATA_VECTOR_S "vector"
#define FXDATA_ANGLE_S "angle"
#define FXDATA_COLOR_S "color"
#define FXDATA_ARRAY_S "array"

#pragma warning(disable:4786)

// FX Data types
enum fxdata_t
{	FXDATA_NONE=0,
	FXDATA_SINGLE,
	FXDATA_VECTOR,
	FXDATA_ARRAY
};

/*
* FX Data Type
*/
class CFXData
{
public:
	/*
	* Constructor
	*/
	CFXData();

	/*
	* Get Name
	*/
	std::string getName( void ) { return m_strName; }

	/*
	* Set Name
	*/
	void setName( std::string strName ) { m_strName = strName; }

	/*
	* Set String Value
	*/
	void setStringValue( std::string strValue ) { m_strValue = strValue; }

	/*
	* Get String Value
	*/
	std::string getStringValue( void ) { return m_strValue; }

	/*
	* Set Vector Value
	*/
	void setVectorValue( vec3_t vecValue ) { m_vecValue = vecValue; }

	/*
	* Get Vector Value
	*/
	vec3_t getVectorValue( void ) { return m_vecValue; }

	/*
	* Add Array
	*/
	void addArray( CFXData add ) { m_Array.push_back(add); }

	/*
	* Get Array
	*/
	std::vector<CFXData> getArray( void ) { return m_Array; }

	/*
	* Get Type
	*/
	fxdata_t getType( void ) { return m_eType; }

	/*
	* Set Type
	*/
	void setType( fxdata_t type ) { m_eType = type; }

	/*
	* parse 3 float
	*/
	bool parse3Float( TiXmlNode* pData, char format[3] );

	/*
	* parse Vector
	*/
	bool parseVector( TiXmlNode* pData );

	/*
	* parse Angle
	*/
	bool parseAngle( TiXmlNode* pData );

	/*
	* parse Color
	*/
	bool parseColor( TiXmlNode* pData );

	/*
	* parse Option
	*/
	bool parseOption( TiXmlNode* pData );

	/*
	* parse Array
	*/
	bool parseArray( TiXmlNode* pData );

	/*
	* Set Data
	* @param TiXmlNode* pData: XML Node containing data
	*/
	bool setData( TiXmlNode* pData );

	/*
	* DEBUG: Print Data
	*/
	void printData( std::string strPrefix );
	
	/*
	* Get Array Size
	*/
	int getArraySize( void );

	/*
	* Get Array At Index
	*/
	CFXData *getArrayAtIndex( int iIndex );

private:
	// Data Type
	fxdata_t m_eType;

	// Data storage
	std::string m_strName;
	std::string m_strValue;
	vec3_t m_vecValue;
	std::vector<CFXData> m_Array;
};

/*
* FX Storage
*/
class CFXStorage
{
public:
	// Constructors
	CFXStorage() {}
	CFXStorage(std::string strImpl) { setImplementation(strImpl); }

	/*
	* Set Implementation
	*/
	void setImplementation( std::string strImpl ) { m_strImplementation = strImpl; }

	/*
	* Get Implementation
	*/
	std::string getImplementation( void ) { return m_strImplementation; }

	/*
	* Set Name
	*/
	void setName( std::string strName ) { m_strName = strName; }

	/*
	* Get Name
	*/
	std::string getName( void ) { return m_strName; }

	/*
	* save Options List
	*/
	void saveOptions( CFXStorage *pStorage );

	/*
	* Add Option
	*/
	void addOption( std::string strName, CFXData fxData );

	/*
	* DEBUG: Print
	*/
	void printData( void );

	/*
	* Get FX Data
	*/
	// Single Varibles
	CFXData *getFXData( std::string strName );
	float getFXDataFloat( std::string strName );
	int getFXDataInt( std::string strName );
	std::string getFXDataString( std::string strName );
	vec3_t getFXDataVector( std::string strName );

	// Range
	void getFXDataFloatRange( float *flRange, std::string strName );
	void getFXDataColorRange( float *flColorA, float *flColorB, std::string strName );
	void getFXDataVectorRange( vec3_t *vecRange, std::string strName );
private:
	std::string m_strName;
	std::string m_strImplementation;
	std::map<std::string,CFXData> m_Options;
};

#endif