summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2TemplatePluginDB.cpp
blob: 7b7b94cad2ef4a6fe64bf757c269cf77e5fa8f39 (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
#include "T2TemplatePlugin.h"
#include "T2TemplatePluginDB.h"
#include "T2TemplatePluginList.h"

T2TemplatePluginDB::T2TemplatePluginDB()
    : LArray(sizeof(T2TemplatePluginList *))
{
}

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

void T2TemplatePluginDB::Regist(T2TemplatePlugin* plugin) {
    if (!plugin)
        return;

    LArrayIterator iterator(*this);
    T2TemplatePluginList *list;
    BOOL found = false;

    while (!found && iterator.Next(&list)) {
        if (list->GetPluginType() == plugin->GetType()) {
            list->Add(plugin);
            found = true;
        }
    }

    if (!found) {
        list = new T2TemplatePluginList(plugin->GetType());
        list->Add(plugin);
        InsertItemsAt(1, mItemCount + 1, &list);
    }
}

void T2TemplatePluginDB::Add(T2TemplatePluginList* list) {
    LArrayIterator iterator(*this);
    T2TemplatePluginList *existingList;
    BOOL found = false;

    while (!found && iterator.Next(&existingList)) {
        if (existingList->GetPluginType() == list->GetPluginType()) {
            LArrayIterator pluginIterator(*list);
            T2TemplatePlugin *plugin;

            while (pluginIterator.Next(&plugin)) {
                existingList->Add(plugin);
            }

            found = true;
        }
    }

    if (!found)
        InsertItemsAt(1, mItemCount + 1, &list);
}

T2TemplatePluginList* T2TemplatePluginDB::GetTemplatePluginList(DWORD pluginType) {
    LArrayIterator iterator(*this);
    T2TemplatePluginList *list;

    while (iterator.Next(&list)) {
        if (list->GetPluginType() == pluginType)
            return list;
    }

    return NULL;
}

T2TenantDef* T2TemplatePluginDB::FindFloor() {
    LArrayIterator iterator(*this);
    T2TemplatePluginList *list;

    while (iterator.Next(&list)) {
        if (list->GetPluginType() == 'TnPl')
            return list->FindFloor();
    }

    return NULL;
}