#include "T2MoverDef.h" #include "T2OuterObjDef.h" #include "T2PeopleDef.h" #include "T2SilhouetteDef.h" #include "T2TemplatePluginList.h" #include "T2TempPluginComparator.h" #include "T2TenantDef.h" T2TemplatePluginList::T2TemplatePluginList(DWORD pluginType) : LArray(sizeof(T2TemplatePlugin *)) { mPluginType = pluginType; SetComparator(T2TempPluginComparator::GetComparator()); mOwnsComparator = false; SetKeepSorted(true); } /*virtual*/ T2TemplatePluginList::~T2TemplatePluginList() { } void T2TemplatePluginList::AllClear() { RemoveItemsAt(mItemCount, 1); } void T2TemplatePluginList::Regist(T2TemplatePlugin* plugin) { if (!plugin) return; InsertItemsAt(1, mItemCount + 1, &plugin); } void T2TemplatePluginList::Add(T2TemplatePlugin* plugin) { if (!plugin) return; InsertItemsAt(1, mItemCount + 1, &plugin); } unsigned int T2TemplatePluginList::GetItemCount() { return GetCount(); } T2TemplatePlugin* T2TemplatePluginList::GetItemAt(int index) { T2TemplatePlugin *plugin; if (FetchItemAt(index, &plugin)) return plugin; else return NULL; } T2TenantDef* T2TemplatePluginList::FindFloor() { if (mPluginType != 'TnDf') return NULL; LArrayIterator iterator(*this); T2TenantDef *theTenantDef; while (iterator.Next(&theTenantDef)) { if (theTenantDef->IsFloor()) return theTenantDef; } return NULL; } T2TenantDef* T2TemplatePluginList::FindTenantDef(int equipType) { if (mPluginType != 'TnDf') return NULL; LArrayIterator iter(*this); T2TenantDef *theTemplatePlugin; while (iter.Next(&theTemplatePlugin)) { if (theTemplatePlugin->GetEquipType() == equipType) return theTemplatePlugin; } return NULL; } T2MoverDef* T2TemplatePluginList::FindMoverDef(int equipType) { if (mPluginType != 'MvDf') return NULL; LArrayIterator iter(*this); T2MoverDef *theTemplatePlugin; while (iter.Next(&theTemplatePlugin)) { if (theTemplatePlugin->GetEquipType() == equipType) return theTemplatePlugin; } return NULL; } T2OuterObjDef* T2TemplatePluginList::FindOutObjDef(int toolType) { if (mPluginType != 'OODf') return NULL; LArrayIterator iter(*this); T2OuterObjDef *theTemplatePlugin; while (iter.Next(&theTemplatePlugin)) { if (theTemplatePlugin->GetToolType() == toolType) return theTemplatePlugin; } return NULL; } T2PeopleDef* T2TemplatePluginList::FindPeopleDef(int peopleType) { if (mPluginType != 'PPDf') return NULL; LArrayIterator iter(*this); T2PeopleDef *theTemplatePlugin; while (iter.Next(&theTemplatePlugin)) { if (theTemplatePlugin->GetPeopleType() == peopleType) return theTemplatePlugin; } return NULL; } T2SilhouetteDef* T2TemplatePluginList::FindSilhouette(int silhouetteType) { if (mPluginType != 'SlDf') return NULL; LArrayIterator iter(*this); T2SilhouetteDef *theTemplatePlugin; while (iter.Next(&theTemplatePlugin)) { if (theTemplatePlugin->GetSilhouetteType() == silhouetteType) return theTemplatePlugin; } return NULL; } int T2TemplatePluginList::CalcCategoryCount() { int numCategory = 0; LArray categoryIDs(sizeof(int)); LArrayIterator theDefIterator(*this); T2ToolDef *def; while (theDefIterator.Next(&def)) { int toolCategoryNo = def->mCategoryNo; BOOL done = false; LArrayIterator theCategoryIterator(categoryIDs); int theCategory; while (theCategoryIterator.Next(&theCategory)) { if (theCategory == toolCategoryNo) { done = true; break; } } if (!done) { categoryIDs.InsertItemsAt(1, categoryIDs.GetCount() + 1, &toolCategoryNo); numCategory++; } } return numCategory; } void T2TemplatePluginList::DispatchIdle(T2TowerDoc* towerDoc) { if (mPluginType != 'OODf' && mPluginType != 'MvDf' && mPluginType != 'TnDf') return; LArrayIterator iter(*this); T2ToolDef *theTemplatePlugin; while (iter.Next(&theTemplatePlugin)) theTemplatePlugin->DefIdleProc(towerDoc); }