diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2RegistedTenantDB.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2RegistedTenantDB.cpp')
-rw-r--r-- | src/T2DLL/T2RegistedTenantDB.cpp | 124 |
1 files changed, 116 insertions, 8 deletions
diff --git a/src/T2DLL/T2RegistedTenantDB.cpp b/src/T2DLL/T2RegistedTenantDB.cpp index 939d158..81d0339 100644 --- a/src/T2DLL/T2RegistedTenantDB.cpp +++ b/src/T2DLL/T2RegistedTenantDB.cpp @@ -1,31 +1,139 @@ +#include "T2EquipPtrList.h" #include "T2RegistedTenantDB.h" +#include "T2RouteNavigator.h" +#include "T2Tenant.h" +#include "T2TenantArray.h" +#include "T2TenantArrayList.h" -T2RegistedTenantDB::T2RegistedTenantDB() { +T2RegistedTenantDB::T2RegistedTenantDB() + : LArray(sizeof(T2EquipPtrList *)) +{ } /*virtual*/ T2RegistedTenantDB::~T2RegistedTenantDB() { + LArrayIterator iterator(*this); + T2EquipPtrList *equipPtrList; + + while (iterator.Next(&equipPtrList)) + delete equipPtrList; } -void T2RegistedTenantDB::Init(T2TenantArrayList*) { +void T2RegistedTenantDB::Init(T2TenantArrayList* tenantArrayList) { + LArrayIterator iterator(*tenantArrayList); + T2TenantArray *tenantArray; + + while (iterator.Next(&tenantArray)) { + for (int i = 0; i < 128; i++) { + T2Tenant *tenant = tenantArray->GetIndexTenant(i); + if (tenant->IsUsed() && !tenant->IsFloor()) + AddItem(tenant); + } + } } -void T2RegistedTenantDB::AddItem(T2Tenant*) { +void T2RegistedTenantDB::AddItem(T2Tenant* tenant) { + if (tenant->IsRegist()) { + unsigned int registID = tenant->GetRegistID(); + T2EquipPtrList *list = GetList(registID); + + if (list) { + list->AddItem(tenant); + } else { + list = new T2EquipPtrList(registID); +#line 55 + _ASSERT(list); + list->AddItem(tenant); + InsertItemsAt(1, mItemCount + 1, &list); + } + } } -void T2RegistedTenantDB::RemoveItem(T2Tenant*) { +void T2RegistedTenantDB::RemoveItem(T2Tenant* tenant) { + if (tenant->IsRegist()) { + unsigned int registID = tenant->GetRegistID(); + T2EquipPtrList *list = GetList(registID); + + if (list) + list->RemoveItem(tenant); + } } -T2EquipPtrList* T2RegistedTenantDB::GetList(unsigned int) const { +T2EquipPtrList* T2RegistedTenantDB::GetList(unsigned int registID) const { + T2EquipPtrList *result = NULL; + LArrayIterator iterator(*this); + + T2EquipPtrList *list; + while (!result && iterator.Next(&list)) { + if (list->GetAttribute() == registID) + result = list; + } + + return result; } -T2Tenant* T2RegistedTenantDB::GetFirstTenant(unsigned int) const { +T2Tenant* T2RegistedTenantDB::GetFirstTenant(unsigned int registID) const { + T2Tenant *tenant = NULL; + T2EquipPtrList *list = GetList(registID); + if (list) + tenant = (T2Tenant *) list->GetItem(1); + return tenant; } -T2Tenant* T2RegistedTenantDB::SearchToilet(const T2RouteNavigator*, POINT, int&) const { +T2Tenant* T2RegistedTenantDB::SearchToilet(const T2RouteNavigator* routeNav, POINT pt, int& outVar) const { + T2Tenant *result = NULL; + outVar = -1; + + T2EquipPtrList *list = GetList(kTenantRegistID7); + if (list) { + LArrayIterator iterator(*list); + T2Tenant *tenant; + while (outVar != 0 && iterator.Next(&tenant)) { + POINT entrancePt = tenant->GetEntrancePt(); + if (routeNav->CheckRoute(pt, entrancePt, tenant->GetCustomerSearchScore())) { + int status = tenant->GetStatus(); + if (status > kTenantStatus9 && status < kTenantStatus10000) { + if (!tenant->WillBeFull()) { + result = tenant; + outVar = 0; + } else { + outVar = -2; + } + } + } + } + } + + return result; } T2Tenant* T2RegistedTenantDB::FindEmptyParking() const { + T2Tenant *result = NULL; + + T2EquipPtrList *list = GetList(kTenantRegistID3); + if (list) { + LArrayIterator iterator(*list); + T2Tenant *tenant; + while (!result && iterator.Next(&tenant)) { + if (tenant->IsEmptyParking()) + result = tenant; + } + } + + return result; } -T2Tenant* T2RegistedTenantDB::FindHisParking(T2People*) const { +T2Tenant* T2RegistedTenantDB::FindHisParking(T2People* people) const { + T2Tenant *result = NULL; + + T2EquipPtrList *list = GetList(kTenantRegistID3); + if (list) { + LArrayIterator iterator(*list); + T2Tenant *tenant; + while (!result && iterator.Next(&tenant)) { + if (tenant->IsBelongPeople(people)) + result = tenant; + } + } + + return result; } |