96 lines
1.7 KiB
C++
96 lines
1.7 KiB
C++
#include "stdafx.h"
|
|
#include "TInterfaceList.h"
|
|
|
|
TInterfaceList::TInterfaceList()
|
|
{
|
|
|
|
}
|
|
|
|
TInterfaceList::~TInterfaceList()
|
|
{
|
|
EraseAll();
|
|
}
|
|
|
|
int TInterfaceList::GetSize() const
|
|
{
|
|
return (int)m_arIntfPtrs.GetSize();
|
|
}
|
|
|
|
void TInterfaceList::RemoveAll()
|
|
{
|
|
m_arIntfPtrs.RemoveAll();
|
|
}
|
|
|
|
TInterface* TInterfaceList::GetAt(int nIndex) const
|
|
{
|
|
return (TInterface*)m_arIntfPtrs.GetAt(nIndex);
|
|
}
|
|
|
|
void TInterfaceList::SetAt(int nIndex, TInterface& intf)
|
|
{
|
|
if (nIndex > -1 && nIndex < m_arIntfPtrs.GetSize())
|
|
{
|
|
(* (TInterface*)m_arIntfPtrs[nIndex]) = intf;
|
|
}
|
|
}
|
|
|
|
int TInterfaceList::Add( TInterface& intf )
|
|
{
|
|
TInterface* pIntf = new TInterface(intf);
|
|
m_arIntfPtrs.Add(pIntf);
|
|
return (int)(m_arIntfPtrs.GetSize() - 1);
|
|
}
|
|
|
|
TInterface* TInterfaceList::operator[](int nIndex) const
|
|
{
|
|
if (nIndex > -1 && nIndex < m_arIntfPtrs.GetSize())
|
|
{
|
|
return (TInterface*)m_arIntfPtrs[nIndex];
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
TInterface*& TInterfaceList::operator[](int nIndex)
|
|
{
|
|
ASSERT (nIndex > -1 && nIndex < m_arIntfPtrs.GetSize());
|
|
return (TInterface*&)m_arIntfPtrs[nIndex];
|
|
}
|
|
|
|
void TInterfaceList::RemoveAt(int nIndex)
|
|
{
|
|
if (nIndex > -1 && nIndex < m_arIntfPtrs.GetSize())
|
|
{
|
|
m_arIntfPtrs.RemoveAt(nIndex);
|
|
}
|
|
}
|
|
|
|
void TInterfaceList::EraseAll()
|
|
{
|
|
TInterface* pIntf = NULL;
|
|
while( m_arIntfPtrs.GetSize() > 0)
|
|
{
|
|
pIntf = (TInterface*)m_arIntfPtrs.GetAt(0);
|
|
if (pIntf != NULL)
|
|
{
|
|
delete pIntf;
|
|
}
|
|
m_arIntfPtrs.RemoveAt(0);
|
|
}
|
|
}
|
|
|
|
void TInterfaceList::Remove(CPtrList& arRemoves)
|
|
{
|
|
POSITION ps;
|
|
TInterface* pIntf = NULL;
|
|
for (int i = 0;i < m_arIntfPtrs.GetSize();i++)
|
|
{
|
|
pIntf = (TInterface*)m_arIntfPtrs.GetAt(i);
|
|
if ( (ps = arRemoves.Find((void*)pIntf)) != NULL)
|
|
{
|
|
m_arIntfPtrs.RemoveAt(i);
|
|
i -= 1;
|
|
arRemoves.RemoveAt(ps);
|
|
delete pIntf;
|
|
}
|
|
}
|
|
} |