OSDN Git Service

e72d6e71d330306aa1baa2bec174563f0d048cac
[gikomona/GikoMona.git] / core / src / model.cpp
1
2 #include "model.hpp"
3
4 namespace monazilla { namespace GikoMona { namespace core {
5
6 struct model::model_pimpl {
7     // session/tab-window
8     database tab_db;
9     // session/history
10     /* 構造
11      *  date()|bbs-name()|board-name()|thread-id()|thread-name()
12      */
13     database history_db;
14     // application
15     config app_config;
16 };
17
18 model::model() noexcept {
19     instance = this;
20     pimpl = std::make_shared<model_pimpl>();
21 }
22
23 model::~model() {}
24
25 bool model::load_file(const boost::filesystem::path& file_path,
26                       const mona_string& loaded_table_name) {
27     if(!boost::filesystem::exists(file_path)) {
28         return false;
29     }
30     
31     return true;
32 }
33
34 void model::exec_inserted_query()  {
35     inserted_query_triv_copyable_type q;
36     if(inserted_query_queue.empty()) {
37         return;
38     } else {
39         inserted_query_queue.pop(q);
40     }
41     
42     mona_string into;
43     boost::any tup;
44     std::tie(*q, into, tup);
45
46     if(into.find_first_of("application", 0, into.length()) != mona_string::npos) {
47         // application/*
48     } else if (into.find_first_of("session", 0, into.length()) != mona_string::npos) {
49         // session/*
50         if(into.find("history", 0, into.length()) != mona_string::npos) {
51             pimpl->history_db.insert(into, tup);
52         } else if(into.find("tab-window") != mona_string::npos != mona_string::npos) {
53             pimpl->tab_db.insert(into, tup);
54         }
55     } else if(into.find_first_of("extension", 0, into.length()) != mona_string::npos) {
56         // extension/*
57     } else {
58         // ?
59     }
60 }
61
62 } } }