diff options
Diffstat (limited to 'src/T2DLL/T2MatterArrayList.cpp')
-rw-r--r-- | src/T2DLL/T2MatterArrayList.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
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; } |