| | @@ -6,27 +6,29 @@ |
6 | 6 | namespace monazilla { namespace GikoMona { namespace core { |
7 | 7 | |
8 | 8 | struct model::model_pimpl { |
| 9 | + |
| 10 | + struct resource_pair { |
| 11 | + database database; |
| 12 | + mona_string file_name; |
| 13 | + }; |
| 14 | + |
| 15 | + // gikomona/config |
| 16 | + resource_pair config; |
| 17 | + |
| 18 | + // ict/board |
| 19 | + resource_pair board; |
| 20 | + |
9 | 21 | // session/tab-window |
10 | 22 | /* 構造 |
11 | 23 | * bbs-name(TEXT)|board-name(TEXT)|thread-id(TEXT)|thread-name(TEXT)|is_fixed(INTEGAR) |
12 | 24 | */ |
13 | | - database tab_db; |
| 25 | + resource_pair tab; |
14 | 26 | |
15 | 27 | // session/history |
16 | 28 | /* 構造 |
17 | 29 | * date(TEXT)|bbs-name(TEXT)|board-name(TEXT)|thread-id(TEXT)|thread-name(TEXT) |
18 | 30 | */ |
19 | | - database history_db; |
20 | | - |
21 | | - // application |
22 | | - config app_config; |
23 | | - |
24 | | - struct { |
25 | | - const mona_string tab_db = "session.tab-window.db"; |
26 | | - const mona_string history_db = "session.history.db"; |
27 | | - const mona_string linkref_db = "session.linkrefs.db"; |
28 | | - const mona_string app_config = "application-config.xml"; |
29 | | - } file_name; |
| 31 | + resource_pair history; |
30 | 32 | }; |
31 | 33 | |
32 | 34 | model::model() noexcept { |
| | @@ -44,17 +46,11 @@ bool model::load_file(const boost::filesystem::path& file_path) { |
44 | 46 | auto ext = file_path.extension(); |
45 | 47 | auto file_name = file_path.filename(); |
46 | 48 | |
47 | | - /* 依存型が欲しいなぁって */ |
48 | | - if(ext == "db") { |
49 | | - // sqlite -> class `database' |
50 | | - if(file_name == pimpl->file_name.tab_db) { |
51 | | - pimpl->tab_db.get_connection().open(file_path.c_str()); |
52 | | - } else if(file_name == pimpl->file_name.history_db) { |
53 | | - pimpl->history_db.get_connection().open(file_path.c_str()); |
54 | | - } |
55 | | - } else if(ext == "xml") { |
56 | | - // xml -> class `config' |
57 | | - pimpl->app_config; |
| 49 | + /* TODO: BOOST_FUSION_ADAPT_STRUCTの利用を検討 */ |
| 50 | + if(file_name == pimpl->file_name.tab_db) { |
| 51 | + pimpl->tab.database.get_connection().open(file_path.c_str()); |
| 52 | + } else if(file_name == pimpl->file_name.history_db) { |
| 53 | + pimpl->history.database.get_connection().open(file_path.c_str()); |
58 | 54 | } |
59 | 55 | |
60 | 56 | return true; |