// Implementation file for the definition of a characteristic base type
////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"

#include "Data\CTL_LDat.hpp"

#include "Data\CTL_DatB.hpp"
#include "Data\CTL_DatI.hpp"
#include "Data\CTL_DatF.hpp"
#include "Data\CTL_DatE.hpp"
#include "Data\CTL_DatT.hpp"
#include "Data\CTL_DatV.hpp"
#include "Data\CTL_DatM.hpp"

//External Modules
#include "CTL_ErO.hpp"
//End of External Modules

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//**************************************************************************************
CTL_Editor_DataList::CTL_Editor_DataList()
{

}

//**************************************************************************************
CTL_Editor_DataList::~CTL_Editor_DataList()
{
	m_fn_vEmptyList();
}

//**************************************************************************************
void CTL_Editor_DataList::m_fn_vEmptyList()
{
	POSITION pos = GetHeadPosition();
	while ( pos != NULL )
		delete GetNext(pos);

	RemoveAll();
}

//*********************************************************************************
CTL_OwnerData *CTL_Editor_DataList::m_pub_fn_pclAddOwnerData(void *_pvDataPtr,
																														 CString _csName)
{
	return m_pri_clListOfOwnerData.m_pub_fn_pclAddOwnerData(_pvDataPtr, _csName);
}

//*********************************************************************************
CTL_OwnerData *CTL_Editor_DataList::m_pub_fn_pclAddOwnerData(long _lData,
																														 CString _csName)
{
	return m_pri_clListOfOwnerData.m_pub_fn_pclAddOwnerData(_lData, _csName);
}

//*********************************************************************************
CTL_OwnerData *CTL_Editor_DataList::m_pub_fn_pclGetOwnerDataWithName(CString _csSearchedName)
{
	return m_pri_clListOfOwnerData.m_pub_fn_pclFindOwnerDataWithName(_csSearchedName);
}

//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddBooleanData(CString csScriptName,
																															CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_BooleanData *pclNewData = new CTL_Editor_BooleanData(csScriptName,
																																	this,
																																	pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddBitFieldBooleanData(tdBitFieldCoder tdBFCoder,
																																			CString csScriptName,
																																			CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_BooleanData *pclNewData = new CTL_Editor_BooleanData(tdBFCoder,
																																	csScriptName,
																																	this,
																																	pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddMaskedData(CTL_Editor_MaskDescriptor *_pclMaskDescriptor,
																														 CString csScriptName,
																														 CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_MaskedData *pclNewData = new CTL_Editor_MaskedData(_pclMaskDescriptor,
																																csScriptName,
																																	this,
																																pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddIntegerData(char cDataLength, 
																															BOOL bSigned, 
																															CString csScriptName,
																															CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_IntegerData *pclNewData = new CTL_Editor_IntegerData(cDataLength, 
																																	bSigned,
																																	csScriptName,
																																	this,
																																	pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddDecimalData(char cDataLength, 
																															CString csScriptName,
																															CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_DecimalData *pclNewData = new CTL_Editor_DecimalData(cDataLength,
																																	csScriptName,
																																	this,
																																	pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddEnumData(CTL_Editor_EnumDescriptor *pclEnumDescriptor, 
																													 CString csScriptName,
																													 CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_EnumData *pclNewData = new CTL_Editor_EnumData(pclEnumDescriptor, 
																														csScriptName,
																														this,
																														pclCurrentBaseData);
 
	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddTextData(CString csScriptName,
																													 CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_TextData *pclNewData = new CTL_Editor_TextData(csScriptName,
																														this,
																														pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclAddVectorData(char cDataLength, 
																														 CString csScriptName,
																														 CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
{
	CTL_Editor_VectorData *pclNewData = new CTL_Editor_VectorData(cDataLength,
																																csScriptName,
																																this,
																																pclCurrentBaseData);

	AddTail(pclNewData);

	return pclNewData;
}

//**************************************************************************************
//To add a user defined data
void CTL_Editor_DataList::m_pub_fn_vAddData(CTL_Editor_Data *_pclDataToAdd)
{
	AddTail(_pclDataToAdd);
}

//**************************************************************************************
CTL_Editor_Data * CTL_Editor_DataList::m_fn_pclGetDataFromName(CString csName)
{
	POSITION						pos=GetHeadPosition();
	CTL_Editor_Data	*pclData=NULL;
	while((pos!=NULL) && (pclData==NULL))
	{
		CTL_Editor_Data	*pclCurrentData=GetNext(pos);

		if(csName.CompareNoCase(pclCurrentData->m_pub_fn_csGetDataName())==0)
			pclData=pclCurrentData;
	}

	return pclData;
}

