#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 *plugin; while (iterator.Next(&plugin)) { if (plugin->IsFloor()) return plugin; } return NULL; } T2TenantDef* T2TemplatePluginList::FindTenantDef(int equipType) { if (mPluginType != 'TnDf') return NULL; LArrayIterator iterator(*this); T2TenantDef *plugin; while (iterator.Next(&plugin)) { if (plugin->GetEquipType() == equipType) return plugin; } return NULL; } T2MoverDef* T2TemplatePluginList::FindMoverDef(int equipType) { if (mPluginType != 'MvDf') return NULL; LArrayIterator iterator(*this); T2MoverDef *plugin; while (iterator.Next(&plugin)) { if (plugin->GetEquipType() == equipType) return plugin; } return NULL; } T2OuterObjDef* T2TemplatePluginList::FindOutObjDef(int toolType) { if (mPluginType != 'OODf') return NULL; LArrayIterator iterator(*this); T2OuterObjDef *plugin; while (iterator.Next(&plugin)) { if (plugin->GetToolType() == toolType) return plugin; } return NULL; } T2PeopleDef* T2TemplatePluginList::FindPeopleDef(int peopleType) { if (mPluginType != 'PPDf') return NULL; LArrayIterator iterator(*this); T2PeopleDef *plugin; while (iterator.Next(&plugin)) { if (plugin->GetPeopleType() == peopleType) return plugin; } return NULL; } T2SilhouetteDef* T2TemplatePluginList::FindSilhouette(int silhouetteType) { if (mPluginType != 'SlDf') return NULL; LArrayIterator iterator(*this); T2SilhouetteDef *plugin; while (iterator.Next(&plugin)) { if (plugin->GetSilhouetteType() == silhouetteType) return plugin; } return NULL; } int T2TemplatePluginList::CalcCategoryCount() { int count = 0; LArray categories(sizeof(int)); LArrayIterator toolDefIterator(*this); T2ToolDef *toolDef; while (toolDefIterator.Next(&toolDef)) { int categoryNo = toolDef->mCategoryNo; BOOL found = false; LArrayIterator categoryIterator(categories); int check; while (categoryIterator.Next(&check)) { if (check == categoryNo) { found = true; break; } } if (!found) { categories.InsertItemsAt(1, categories.GetCount() + 1, &categoryNo); count++; } } return count; } void T2TemplatePluginList::DispatchIdle(T2TowerDoc* towerDoc) { if (mPluginType != 'OODf' && mPluginType != 'MvDf' && mPluginType != 'TnDf') return; LArrayIterator iterator(*this); T2ToolDef *toolDef; while (iterator.Next(&toolDef)) toolDef->DefIdleProc(towerDoc); }