/**********************************************************************************************

		MCFixedSizeArray.h



		Copyright: (c) 2001 Eovia Corp. All rights reserved.


		Author:	Nicolas
		Date:	01/20/99

		Fixed size array
	
		Revision History

		when		who			what & why
		==========	==========	======================================================
		8/1/99		Ian			Pro5 compiler fixes.
		01/22/99	Nba			Changed operator [] and cast operator for MW

**********************************************************************************************/

#ifndef __MCFixedSizeArray__
#define __MCFixedSizeArray__

#include "MCBasicTypes.h"
#include "MCAssert.h"

#pragma once


/// Deprecated, do not use.
///
template <class T, int32 i> class TMCFixedSizeArray
{
public:
	TMCFixedSizeArray	() {}
	TMCFixedSizeArray	(const TMCFixedSizeArray<T,i>& other) { *this = other; }

	const T& operator[](int index) const { MCAssert(index >= 0 && index < i); return fComps[index]; }
	T& operator[](int index) { MCAssert(index >= 0 && index < i); return fComps[index]; }


	inline  boolean operator==(const TMCFixedSizeArray<T,i>& other) const;
			boolean operator!=(const TMCFixedSizeArray<T,i>& other) const { return !(*this == other); }

	inline TMCFixedSizeArray<T, i> &operator=(const TMCFixedSizeArray<T, i> &other);

	T* GetBaseAddress() { return fComps; }
	const T* GetBaseAddress() const { return fComps; }
	inline TMCFixedSizeArray<T,i>& operator+=	(TMCFixedSizeArray<T,i>& other);
	inline TMCFixedSizeArray<T,i>& operator*=	(TMCFixedSizeArray<T,i>& other);
	inline TMCFixedSizeArray<T,i>& operator/=	(TMCFixedSizeArray<T,i>& other);
	inline TMCFixedSizeArray<T,i>& operator<<=	(int32 v);
	inline TMCFixedSizeArray<T,i>& operator>>=	(int32 v);
	inline TMCFixedSizeArray<T,i>& Blend		(TMCFixedSizeArray<T,i>& other, T factor);

protected:
	T fComps[i];
};


template <class T,int32 i> inline boolean TMCFixedSizeArray<T,i>::operator==(const TMCFixedSizeArray<T,i>& other) const
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		if (fComps[index] != other[index]) return false;
	}
	return true;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T, i>::operator=(const TMCFixedSizeArray<T,i>& other)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index] = other[index];
	}
	return *this;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T, i>::operator +=(TMCFixedSizeArray<T,i>& other)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index] += other[index];
	}
	return *this;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T,i>::operator *=(TMCFixedSizeArray<T, i>& other)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index] *= other[index];
	}
	return *this;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T, i>::operator /=(TMCFixedSizeArray<T, i>& other)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index] /= other[index];
	}
	return *this;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T, i>::operator <<=(int32 v)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index] <<= v;
	}
	return *this;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T, i>::operator >>=(int32 v)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index] >>= v;
	}
	return *this;
}

template <class T,int32 i> inline TMCFixedSizeArray<T,i>& TMCFixedSizeArray<T, i>::Blend(TMCFixedSizeArray<T,i>& other, T factor)
{
	int32 index;
	for(index = 0; index < i; index++)
	{
		fComps[index].Blend(other[index], factor);
	}
	return *this;
}



#endif