OSDN Git Service

[core] : modelへの関数追加とoptimize_database()の実装を追加。
authorcaprice <caprice@users.sourceforge.jp>
Sun, 23 Jun 2013 16:00:36 +0000 (01:00 +0900)
committercaprice <caprice@users.sourceforge.jp>
Sun, 23 Jun 2013 16:14:07 +0000 (01:14 +0900)
core/src/GikoMona.cpp

index 5432e18..d224c41 100644 (file)
@@ -1,4 +1,5 @@
 #include <wx/xrc/xmlres.h>
+#include <wx/msgdlg.h>
 
 #include "GikoMona.hpp"
 #include "database.hpp"
@@ -14,10 +15,7 @@ model *app_model;
 
 bool init_core() {
     wxXmlResource::Get()->InitAllHandlers();
-    wxXmlResource::Get()->LoadAllFiles(wxT(""));
-    
-    database db;
-    db.run_sql("");
+    wxXmlResource::Get()->LoadAllFiles(wxT("resouce"));
     
     app_model = new model;
     model::get_instance()->load_file("./config.xml");
@@ -26,7 +24,23 @@ bool init_core() {
 }
 
 void done_core() noexcept {
+    model::get_instance()->save_to_file("./config.xml", "config");
+    model::get_instance()->save_to_file("./saved-tab-session.xml",
+                                        "session/tab");
+    model::get_instance()->save_to_file("./history.db", "session/history");
+    
+    optimize_database("./history.db");
+
     delete app_model;
 }
 
+void optimize_database(const boost::filesystem::path& db_path) {
+    database db("./history.db");
+    auto q = query<int>().define()
+        .select("count-of-deleting-values", "file-infomation");
+    if(db.do_query(q) >= 5000) {
+        db.optimize();
+    }
+}
+
 } } }