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

		MCArrayUtils.h
		Copyright: (c) 2002 Eovia Corp. All rights reserved.

		Author:	Arnaud
		Date:	9/27/2006

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

#ifndef __MCArrayUtils__
#define __MCArrayUtils__

#if CP_PRAGMA_ONCE
#pragma once
#endif


#include "MCCompObj.h"
#include "MCCountedPtr.h"


template < class TArray1, class TArray2 > void QueryArray(	const MCIID&	iid,
															const TArray1&	inArray,
															TArray2&		outArray)
{
	const int32 elemsCount= inArray.GetElemCount();
	outArray.SetElemCount(elemsCount);
	for (int32 elemNdx= 0; elemNdx < elemsCount; elemNdx++)
	{
		TMCCountedPtr< typename TArray2::TTemplateType > tmp;
		inArray[elemNdx]->QueryInterface(iid, (void **)&tmp);
		outArray.SetElem(elemNdx, tmp);
	}
}


template < class TArray1, class TArray2 > void CopyArray(	const TArray1&	inArray,
															TArray2&		outArray)
{
	const int32 elemsCount= inArray.GetElemCount();
	outArray.SetElemCount(elemsCount);
	for (int32 elemNdx= 0; elemNdx < elemsCount; elemNdx++)
	{
		outArray.SetElem(elemNdx, inArray[elemNdx]);
	}
}

template < class TArray1, class TArray2 > void CopyCastArray(	const TArray1&	inArray,
																TArray2&		outArray)
{
	const int32 elemsCount= inArray.GetElemCount();
	outArray.SetElemCount(elemsCount);
	for (int32 elemNdx= 0; elemNdx < elemsCount; elemNdx++)
	{
		outArray.SetElem(elemNdx, static_cast<typename TArray2::TValueType>(inArray[elemNdx]));
	}
}



#endif
