summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2RegistedTenantIterator.cpp
blob: c9597c0f829e30765f5fec18d5f6afbbb4f6edcb (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
#include "T2EquipPtrList.h"
#include "T2RegistedTenantDB.h"
#include "T2RegistedTenantIterator.h"
#include "T2RouteNavigator.h"
#include "T2Tenant.h"

T2RegistedTenantIterator::T2RegistedTenantIterator(const T2RegistedTenantDB* db, unsigned int registID, const T2RouteNavigator* routeNavigator, POINT point) {
    mEquipPtrList = db->GetList(registID);
    mRouteNavigator = routeNavigator;

    if (mEquipPtrList && mRouteNavigator) {
        mIndex = 0;
        mPoint = point;
    } else {
        mIndex = -2;
    }
}

T2RegistedTenantIterator::~T2RegistedTenantIterator() {
}

BOOL T2RegistedTenantIterator::Next(T2Tenant*& pTenant) {
    BOOL result = false;
    BOOL done = false;
    T2Tenant *tenant = NULL;

    while (!done) {
        mIndex++;

        if (mIndex > 0 && mEquipPtrList->FetchItemAt(mIndex, &tenant)) {
            int status = tenant->GetStatus();
            if (status > 9 && status < 10000) {
                POINT entrancePt = tenant->GetEntrancePt();
                if (mRouteNavigator->CheckRoute(mPoint, entrancePt, tenant->GetCustomerSearchScore())) {
                    pTenant = tenant;
                    result = true;
                    done = true;
                }
            }
        } else {
            done = true;
        }
    }

    return result;
}

BOOL T2RegistedTenantIterator::NextJob(T2Tenant*& pTenant) {
    BOOL result = false;
    BOOL done = false;
    T2Tenant *tenant = NULL;

    while (!done) {
        mIndex++;

        if (mIndex > 0 && mEquipPtrList->FetchItemAt(mIndex, &tenant)) {
            int status = tenant->GetStatus();
            if (status > 9 && status < 10000) {
                POINT entrancePt = tenant->GetEntrancePt();
                if (mRouteNavigator->CheckRoute(mPoint, entrancePt, tenant->GetEmployeeSearchScore())) {
                    pTenant = tenant;
                    result = true;
                    done = true;
                }
            }
        } else {
            done = true;
        }
    }

    return result;
}