#include "T2EquipPtrList.h" #include "T2RegistedTenantDB.h" #include "T2RouteNavigator.h" #include "T2Tenant.h" #include "T2TenantArray.h" #include "T2TenantArrayList.h" T2RegistedTenantDB::T2RegistedTenantDB() : LArray(sizeof(T2EquipPtrList *)) { } /*virtual*/ T2RegistedTenantDB::~T2RegistedTenantDB() { LArrayIterator iterator(*this); T2EquipPtrList *equipPtrList; while (iterator.Next(&equipPtrList)) delete equipPtrList; } 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* tenant) { if (tenant->IsRegist()) { unsigned int theRegistID = tenant->GetRegistID(); T2EquipPtrList *theList = GetList(theRegistID); if (theList) { theList->AddItem(tenant); } else { theList = new T2EquipPtrList(theRegistID); #line 55 _ASSERT(theList != NULL); theList->AddItem(tenant); InsertItemsAt(1, mItemCount + 1, &theList); } } } void T2RegistedTenantDB::RemoveItem(T2Tenant* tenant) { if (tenant->IsRegist()) { unsigned int theRegistID = tenant->GetRegistID(); T2EquipPtrList *theList = GetList(theRegistID); if (theList) theList->RemoveItem(tenant); } } 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 registID) const { T2Tenant *theFirstTenant = NULL; T2EquipPtrList *theList = GetList(registID); if (theList) theFirstTenant = (T2Tenant *) theList->GetItem(1); return theFirstTenant; } T2Tenant* T2RegistedTenantDB::SearchToilet(const T2RouteNavigator* inNavi, POINT inPt, int& outVar) const { T2Tenant *theSearchToilet = NULL; outVar = -1; T2EquipPtrList *theRegistList = GetList(kTenantRegistID7); if (theRegistList) { LArrayIterator theTenantIter(*theRegistList); T2Tenant *theTenant; while (outVar != 0 && theTenantIter.Next(&theTenant)) { POINT entrancePt = theTenant->GetEntrancePt(); if (inNavi->CheckRoute(inPt, entrancePt, theTenant->GetCustomerSearchScore())) { int status = theTenant->GetStatus(); if (status > kTenantStatus9 && status < kTenantStatus10000) { if (!theTenant->WillBeFull()) { theSearchToilet = theTenant; outVar = 0; } else { outVar = -2; } } } } } return theSearchToilet; } T2Tenant* T2RegistedTenantDB::FindEmptyParking() const { T2Tenant *theParking = NULL; T2EquipPtrList *theRegistList = GetList(kTenantRegistID3); if (theRegistList) { LArrayIterator theTenantIter(*theRegistList); T2Tenant *theTenant; while (!theParking && theTenantIter.Next(&theTenant)) { if (theTenant->IsEmptyParking()) theParking = theTenant; } } return theParking; } T2Tenant* T2RegistedTenantDB::FindHisParking(T2People* people) const { T2Tenant *hisParking = NULL; T2EquipPtrList *theRegistList = GetList(kTenantRegistID3); if (theRegistList) { LArrayIterator theTenantIter(*theRegistList); T2Tenant *theTenant; while (!hisParking && theTenantIter.Next(&theTenant)) { if (theTenant->IsBelongPeople(people)) hisParking = theTenant; } } return hisParking; }