summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2ToolDefDB.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-07-01 02:43:29 +0100
committerAsh Wolf <ninji@wuffs.org>2023-07-01 02:43:29 +0100
commit5c6a48b2ff362a70416a6a00fda7d06e0f276f2d (patch)
tree62cf542c68d91aa6f7a4e3bfa9eddca4ab352970 /src/T2DLL/T2ToolDefDB.cpp
parentc0c336500955a23e344651e5412c9d9d441ef4ee (diff)
downloadt2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.tar.gz
t2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.zip
i am in hell
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2ToolDefDB.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/T2DLL/T2ToolDefDB.cpp b/src/T2DLL/T2ToolDefDB.cpp
new file mode 100644
index 0000000..0f12394
--- /dev/null
+++ b/src/T2DLL/T2ToolDefDB.cpp
@@ -0,0 +1,92 @@
+#include "T2ToolDef.h"
+#include "T2ToolDefDB.h"
+#include "T2ToolDefList.h"
+
+T2ToolDefDB::T2ToolDefDB()
+ : LArray(sizeof(T2ToolDefList *))
+{
+}
+
+/*virtual*/ T2ToolDefDB::~T2ToolDefDB() {
+}
+
+void T2ToolDefDB::AllClear() {
+ RemoveItemsAt(mItemCount, 1);
+}
+
+void T2ToolDefDB::Regist(T2ToolDef* inToolDef) {
+ if (!inToolDef)
+ return;
+
+ int categoryNo = inToolDef->GetCategory();
+ int n = 1;
+ LArrayIterator iterator(*this);
+ T2ToolDefList *theToolDefList;
+ BOOL added = false;
+
+ while (!added && iterator.Next(&theToolDefList)) {
+ int thisCategory = theToolDefList->GetCategory();
+ if (thisCategory == categoryNo) {
+ theToolDefList->Add(inToolDef);
+ added = true;
+ } else {
+ if (thisCategory > categoryNo)
+ break;
+ }
+
+ n++;
+ }
+
+ if (!added) {
+ theToolDefList = new T2ToolDefList(categoryNo);
+ theToolDefList->Add(inToolDef);
+ InsertItemsAt(1, n, &theToolDefList);
+ }
+}
+
+void T2ToolDefDB::Add(T2ToolDefList* inToolDefList) {
+ LArrayIterator iterator(*this);
+ T2ToolDefList *theToolDefList;
+ BOOL added = false;
+
+ while (!added && iterator.Next(&theToolDefList)) {
+ if (theToolDefList->GetCategory() == inToolDefList->GetCategory()) {
+ LArrayIterator toolDefIterator(*inToolDefList);
+ T2ToolDef *theToolDef;
+
+ while (toolDefIterator.Next(&theToolDef))
+ theToolDefList->Add(theToolDef);
+
+ added = true;
+ }
+ }
+
+ if (!added)
+ InsertItemsAt(1, mItemCount + 1, &inToolDefList);
+}
+
+T2ToolDefList* T2ToolDefDB::GetToolDefList(int inCategory) {
+ LArrayIterator iterator(*this);
+ T2ToolDefList *theToolDefList;
+
+ while (iterator.Next(&theToolDefList)) {
+ if (theToolDefList->GetCategory() == inCategory)
+ return theToolDefList;
+ }
+
+ return NULL;
+}
+
+T2TenantDef* T2ToolDefDB::FindFloor() {
+ LArrayIterator iterator(*this);
+ T2ToolDefList *theToolDefList;
+ T2TenantDef *theFloor = NULL;
+
+ while (iterator.Next(&theToolDefList)) {
+ theFloor = theToolDefList->FindFloor();
+ if (theFloor)
+ return theFloor;
+ }
+
+ return NULL;
+}