From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2MatterArrayList.cpp | 54 +++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'src/T2DLL/T2MatterArrayList.cpp') diff --git a/src/T2DLL/T2MatterArrayList.cpp b/src/T2DLL/T2MatterArrayList.cpp index d53785e..5611373 100644 --- a/src/T2DLL/T2MatterArrayList.cpp +++ b/src/T2DLL/T2MatterArrayList.cpp @@ -1,25 +1,59 @@ +#include "T2MatterArray.h" #include "T2MatterArrayList.h" -T2MatterArrayList::T2MatterArrayList(const T2MatterArrayList&) { -} - -T2MatterArrayList& T2MatterArrayList::operator=(const T2MatterArrayList&) { -} - -T2MatterArrayList::T2MatterArrayList() { +T2MatterArrayList::T2MatterArrayList() + : LArray(sizeof(T2MatterArray *)) +{ + T2MatterArray *theArray = new T2MatterArray(0, T2MatterArray::kGroupSize, 1); + Add(theArray); } /*virtual*/ T2MatterArrayList::~T2MatterArrayList() { + LArrayIterator iterator(*this); + T2MatterArray *theArray; + + while (iterator.Next(&theArray)) + delete theArray; } -void T2MatterArrayList::Add(T2MatterArray*) { +void T2MatterArrayList::Add(T2MatterArray* inArray) { + InsertItemsAt(1, mItemCount + 1, &inArray); } unsigned int T2MatterArrayList::GetItemCount() { + return GetCount(); } -T2MatterArray* T2MatterArrayList::GetItemAt(long) { +T2MatterArray* T2MatterArrayList::GetItemAt(long inIndex) { + T2MatterArray *theArray; + if (FetchItemAt(inIndex, &theArray)) + return theArray; + return NULL; } -T2Matter* T2MatterArrayList::FindUnusedMatter(unsigned int, unsigned int) { +T2Matter* T2MatterArrayList::FindUnusedMatter(unsigned int inJobType, unsigned int inValidRange) { + LArrayIterator iterator(*this); + unsigned int lastStartID = 1; + T2MatterArray *theArray; + + while (iterator.Next(&theArray)) { + if (theArray->GetJobType() == inJobType) { + T2Matter *theMatter = theArray->FindUnusedMatter(inValidRange); + if (theMatter) + return theMatter; + + lastStartID = theArray->mStartID; + } + } + + if (inValidRange > 0) { + theArray = new T2MatterArray(inJobType, inValidRange, lastStartID + T2MatterArray::kGroupSize); + if (theArray) { + Add(theArray); + return theArray->FindUnusedMatter(0); + } + return NULL; + } + + return NULL; } -- cgit v1.2.3