summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2ToolDefList.cpp
blob: cf359ce9dbd67565d925eaa2855276fa92011d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "T2TempPluginComparator.h"
#include "T2TenantDef.h"
#include "T2ToolDef.h"
#include "T2ToolDefList.h"

T2ToolDefList::T2ToolDefList(int inCategory)
    : LArray(sizeof(T2TemplatePlugin *))
{
    mCategory = inCategory;

    SetComparator(T2TempPluginComparator::GetComparator());
    mOwnsComparator = false;
    SetKeepSorted(true);

    mCurrentItem = 1;
    mCurrentVariant = 0;
}

/*virtual*/ T2ToolDefList::~T2ToolDefList() {
}

void T2ToolDefList::AllClear() {
    RemoveItemsAt(mItemCount, 1);
}

void T2ToolDefList::Regist(T2ToolDef* inToolDef) {
    InsertItemsAt(1, mItemCount + 1, &inToolDef);
}

void T2ToolDefList::Add(T2ToolDef* inToolDef) {
    if (!inToolDef)
        return;

    LArrayIterator iterator(*this);
    T2ToolDef *theToolDef;
    BOOL done = false;
    int n = 1;

    while (!done && iterator.Next(&theToolDef)) {
        if (theToolDef->GetToolNo() < inToolDef->GetToolNo()) {
            InsertItemsAt(1, n, &inToolDef);
            done = true;
        }
        n++;
    }

    if (!done)
        InsertItemsAt(1, n, &inToolDef);
}

unsigned int T2ToolDefList::GetItemCount() {
    return GetCount();
}

T2ToolDef* T2ToolDefList::GetItemAt(int inIndex) {
    T2ToolDef *theToolDef;
    if (FetchItemAt(inIndex, &theToolDef))
        return theToolDef;
    else
        return NULL;
}

T2TenantDef* T2ToolDefList::FindFloor() {
    T2ToolDef *theTool;
    LArrayIterator iterator(*this);

    while (iterator.Next(&theTool)) {
        if (theTool->IsTenant() && ((T2TenantDef *) theTool)->IsFloor())
            return (T2TenantDef *) theTool;
    }

    return NULL;
}

T2TenantDef* T2ToolDefList::FindTenantDef(int inToolType) {
    T2ToolDef *theTool;
    LArrayIterator iterator(*this);

    while (iterator.Next(&theTool)) {
        if (theTool->IsTenant() && theTool->GetToolType() == inToolType)
            return (T2TenantDef *) theTool;
    }

    return NULL;
}

T2MoverDef* T2ToolDefList::FindMoverDef(int inToolType) {
    T2ToolDef *theTool;
    LArrayIterator iterator(*this);

    while (iterator.Next(&theTool)) {
        if (theTool->IsMover() && theTool->GetToolType() == inToolType)
            return (T2MoverDef *) theTool;
    }

    return NULL;
}