348 lines
9.7 KiB
C++
348 lines
9.7 KiB
C++
// EdIRICLs.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Defines.hpp"
|
|
|
|
#ifdef D_ED_IR_ACTIVE
|
|
|
|
#include "EdIRICLs.hpp"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
// class CPA_EdIR_IntermediateCodeNode
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
CPA_EdIR_IntermediateCodeList::CPA_EdIR_IntermediateCodeNode::CPA_EdIR_IntermediateCodeNode(CPA_EdIR_IntermediateCode *pclData)
|
|
{
|
|
m_pclData=pclData;
|
|
m_pclNextNode=NULL;
|
|
}
|
|
|
|
CPA_EdIR_IntermediateCodeList::CPA_EdIR_IntermediateCodeNode::~CPA_EdIR_IntermediateCodeNode()
|
|
{
|
|
delete m_pclData;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
// class CPA_EdIR_IntermediateCodeList
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCodeList::CPA_EdIR_IntermediateCodeList()
|
|
{
|
|
m_pclIntermediateCodeHead=NULL;
|
|
m_pclIntermediateCodeTail=NULL;
|
|
m_lNbEntries=0;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCodeList::CPA_EdIR_IntermediateCodeList(CPA_EdIR_IntermediateCodeList &clIntermediateCodeList)
|
|
{
|
|
m_pclIntermediateCodeHead=clIntermediateCodeList.m_pclIntermediateCodeHead;
|
|
m_pclIntermediateCodeTail=clIntermediateCodeList.m_pclIntermediateCodeTail;
|
|
m_lNbEntries=clIntermediateCodeList.m_lNbEntries;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCodeList::~CPA_EdIR_IntermediateCodeList()
|
|
{
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vDestroyAndRemoveAllEntries()
|
|
{
|
|
CPA_EdIR_IntermediateCodeNode *pclCurrentNode=m_pclIntermediateCodeHead;
|
|
CPA_EdIR_IntermediateCodeNode *pclTmpNode;
|
|
while(pclCurrentNode!=NULL)
|
|
{
|
|
pclTmpNode=pclCurrentNode->m_pclNextNode;
|
|
|
|
delete pclCurrentNode;
|
|
|
|
pclCurrentNode=pclTmpNode;
|
|
}
|
|
|
|
m_pclIntermediateCodeHead=NULL;
|
|
m_pclIntermediateCodeTail=NULL;
|
|
m_lNbEntries=0;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vMakeEmpty()
|
|
{
|
|
m_pclIntermediateCodeHead=NULL;
|
|
m_pclIntermediateCodeTail=NULL;
|
|
m_lNbEntries=0;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
BOOL CPA_EdIR_IntermediateCodeList::IsEmpty()
|
|
{
|
|
return m_lNbEntries==0;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
long CPA_EdIR_IntermediateCodeList::GetCount()
|
|
{
|
|
return m_lNbEntries;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::AddTail(CPA_EdIR_IntermediateCode *pclIntermediateCode)
|
|
{
|
|
m_fn_vAdd(pclIntermediateCode);
|
|
}
|
|
|
|
/****************************************************************************/
|
|
POSITION CPA_EdIR_IntermediateCodeList::FindIndex(long lIndex)
|
|
{
|
|
CPA_EdIR_IntermediateCodeNode *pclCurrentNode=m_pclIntermediateCodeHead;
|
|
long lCurrentIndex=0;
|
|
while(pclCurrentNode!=NULL && lCurrentIndex<lIndex)
|
|
{
|
|
pclCurrentNode=pclCurrentNode->m_pclNextNode;
|
|
lCurrentIndex++;
|
|
}
|
|
|
|
return (POSITION)pclCurrentNode;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
POSITION CPA_EdIR_IntermediateCodeList::GetHeadPosition()
|
|
{
|
|
return (POSITION)m_pclIntermediateCodeHead;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCode *CPA_EdIR_IntermediateCodeList::GetAt(POSITION pos)
|
|
{
|
|
ASSERT(pos!=NULL);
|
|
|
|
return ((CPA_EdIR_IntermediateCodeNode *)pos)->m_pclData;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCode *CPA_EdIR_IntermediateCodeList::GetNext(POSITION &pos)
|
|
{
|
|
ASSERT(pos!=NULL);
|
|
|
|
CPA_EdIR_IntermediateCodeNode *pclNode=(CPA_EdIR_IntermediateCodeNode *)pos;
|
|
|
|
pos=(POSITION)pclNode->m_pclNextNode;
|
|
|
|
return pclNode->m_pclData;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCode *CPA_EdIR_IntermediateCodeList::GetHead()
|
|
{
|
|
if(m_pclIntermediateCodeHead!=NULL)
|
|
return m_pclIntermediateCodeHead->m_pclData;
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCode *CPA_EdIR_IntermediateCodeList::GetTail()
|
|
{
|
|
if(m_pclIntermediateCodeTail!=NULL)
|
|
return m_pclIntermediateCodeTail->m_pclData;
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vAdd(long lOffset,tdeNodeType eNodeType,long lIndex,CPA_Actor *pclModel)
|
|
{
|
|
CPA_EdIR_IntermediateCode *pclIntermediateCode=new CPA_EdIR_IntermediateCode(lOffset,eNodeType,lIndex,pclModel);
|
|
|
|
m_fn_vAdd(pclIntermediateCode);
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vAdd(long lOffset,tdeNodeType eNodeType,double dfValue)
|
|
{
|
|
CPA_EdIR_IntermediateCode *pclIntermediateCode=new CPA_EdIR_IntermediateCode(lOffset,eNodeType,dfValue);
|
|
|
|
m_fn_vAdd(pclIntermediateCode);
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vAdd(long lOffset,tdeNodeType eNodeType,CString csString)
|
|
{
|
|
CPA_EdIR_IntermediateCode *pclIntermediateCode=new CPA_EdIR_IntermediateCode(lOffset,eNodeType,csString);
|
|
|
|
m_fn_vAdd(pclIntermediateCode);
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vAdd(CPA_EdIR_IntermediateCode *pclIntermediateCode)
|
|
{
|
|
if(m_lNbEntries==0)
|
|
{
|
|
m_pclIntermediateCodeHead=new CPA_EdIR_IntermediateCodeNode(pclIntermediateCode);
|
|
m_pclIntermediateCodeTail=m_pclIntermediateCodeHead;
|
|
}
|
|
else
|
|
{
|
|
m_pclIntermediateCodeTail->m_pclNextNode=new CPA_EdIR_IntermediateCodeNode(pclIntermediateCode);
|
|
m_pclIntermediateCodeTail=m_pclIntermediateCodeTail->m_pclNextNode;
|
|
}
|
|
|
|
m_lNbEntries++;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vConcat(CPA_EdIR_IntermediateCodeList &clIntermediateCodeList)
|
|
{
|
|
if(clIntermediateCodeList.m_lNbEntries!=0)
|
|
{
|
|
if(m_lNbEntries==0)
|
|
{
|
|
m_pclIntermediateCodeHead=clIntermediateCodeList.m_pclIntermediateCodeHead;
|
|
m_pclIntermediateCodeTail=clIntermediateCodeList.m_pclIntermediateCodeTail;
|
|
}
|
|
else
|
|
{
|
|
m_pclIntermediateCodeTail->m_pclNextNode=clIntermediateCodeList.m_pclIntermediateCodeHead;
|
|
m_pclIntermediateCodeTail=clIntermediateCodeList.m_pclIntermediateCodeTail;
|
|
}
|
|
|
|
m_lNbEntries+=clIntermediateCodeList.m_lNbEntries;
|
|
}
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCodeList CPA_EdIR_IntermediateCodeList::operator =(CPA_EdIR_IntermediateCodeList &clIntermediateCodeList)
|
|
{
|
|
m_pclIntermediateCodeHead=clIntermediateCodeList.m_pclIntermediateCodeHead;
|
|
m_pclIntermediateCodeTail=clIntermediateCodeList.m_pclIntermediateCodeTail;
|
|
m_lNbEntries=clIntermediateCodeList.m_lNbEntries;
|
|
|
|
return *this;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CPA_EdIR_IntermediateCodeList CPA_EdIR_IntermediateCodeList::operator =(CPA_EdIR_IntermediateCode *pclIntermediateCode)
|
|
{
|
|
m_pclIntermediateCodeHead=new CPA_EdIR_IntermediateCodeNode(pclIntermediateCode);
|
|
m_pclIntermediateCodeTail=m_pclIntermediateCodeHead;
|
|
m_lNbEntries=1;
|
|
|
|
return *this;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
CString CPA_EdIR_IntermediateCodeList::m_fn_csGetValue(long lIndex)
|
|
{
|
|
CString csValue;
|
|
POSITION pos=FindIndex(lIndex);
|
|
|
|
if(pos!=NULL)
|
|
{
|
|
csValue=GetAt(pos)->m_fn_csGetValue();
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("[DEV CPA_EdIR_IntermediateCodeList::m_fn_csGetValue] pos==NULL !!");
|
|
}
|
|
|
|
return csValue;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
long CPA_EdIR_IntermediateCodeList::m_fn_lGetIndex(long lIndex)
|
|
{
|
|
long lIndexRes=-1;
|
|
POSITION pos=FindIndex(lIndex);
|
|
|
|
if(pos!=NULL)
|
|
{
|
|
lIndexRes=GetAt(pos)->m_fn_lGetIndex();
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("[DEV CPA_EdIR_IntermediateCodeList::m_fn_lGetIndex] pos==NULL !!");
|
|
}
|
|
|
|
return lIndexRes;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
double CPA_EdIR_IntermediateCodeList::m_fn_dfGetValue(long lIndex)
|
|
{
|
|
double dfValue=0.0;
|
|
POSITION pos=FindIndex(lIndex);
|
|
|
|
if(pos!=NULL)
|
|
{
|
|
dfValue=GetAt(pos)->m_fn_dfGetValue();
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("[DEV CPA_EdIR_IntermediateCodeList::m_fn_dfGetValue] pos==NULL !!");
|
|
}
|
|
|
|
return dfValue;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
MTH3D_tdstVector CPA_EdIR_IntermediateCodeList::m_fn_tdstGetVector(long lIndex)
|
|
{
|
|
MTH3D_tdstVector tdstVector;
|
|
POSITION pos=FindIndex(lIndex);
|
|
|
|
MTH3D_M_vNullVector(&(tdstVector));
|
|
|
|
if(pos!=NULL)
|
|
{
|
|
tdstVector=GetAt(pos)->m_fn_tdstGetVector();
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("[DEV CPA_EdIR_IntermediateCodeList::m_fn_tdstGetVector] pos==NULL !!");
|
|
}
|
|
|
|
return tdstVector;
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vSetIndex(long lIndex,long lValue)
|
|
{
|
|
long lIndexRes=-1;
|
|
POSITION pos=FindIndex(lIndex);
|
|
|
|
if(pos!=NULL)
|
|
{
|
|
GetAt(pos)->m_fn_vSetIndex(lValue);
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("[DEV CPA_EdIR_IntermediateCodeList::m_fn_vSetIndex] pos==NULL !!");
|
|
}
|
|
}
|
|
|
|
/****************************************************************************/
|
|
void CPA_EdIR_IntermediateCodeList::m_fn_vSetModel(long lIndex,CPA_Actor *pclModel)
|
|
{
|
|
long lIndexRes=-1;
|
|
POSITION pos=FindIndex(lIndex);
|
|
|
|
if(pos!=NULL)
|
|
{
|
|
GetAt(pos)->m_fn_vSetModel(pclModel);
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("[DEV CPA_EdIR_IntermediateCodeList::m_fn_vSetModel] pos==NULL !!");
|
|
}
|
|
}
|
|
|
|
#endif //D_ED_IR_ACTIVE
|