1 | // ============================================================= // |
---|
2 | // // |
---|
3 | // File : DI_main.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // ============================================================= // |
---|
10 | |
---|
11 | // #define FINDCORR |
---|
12 | |
---|
13 | #include <servercntrl.h> |
---|
14 | #include <awt.hxx> |
---|
15 | #include <awt_canvas.hxx> |
---|
16 | |
---|
17 | #include <aw_preset.hxx> |
---|
18 | #include <aw_root.hxx> |
---|
19 | #include <aw_msg.hxx> |
---|
20 | #include <arbdb.h> |
---|
21 | |
---|
22 | |
---|
23 | AW_HEADER_MAIN |
---|
24 | |
---|
25 | AW_window *DI_create_matrix_window(AW_root *aw_root); |
---|
26 | void DI_create_matrix_variables(AW_root *aw_root, AW_default aw_def, AW_default db); |
---|
27 | #ifdef FINDCORR |
---|
28 | AW_window *bc_create_main_window(AW_root *awr); |
---|
29 | void bc_create_bc_variables(AW_root *awr, AW_default awd); |
---|
30 | #endif |
---|
31 | |
---|
32 | GBDATA *GLOBAL_gb_main; // global gb_main for arb_dist |
---|
33 | |
---|
34 | |
---|
35 | static void DI_timer(AW_root *aw_root, AW_CL cl_gbmain, AW_CL cd2) { |
---|
36 | GBDATA *gb_main = reinterpret_cast<GBDATA*>(cl_gbmain); |
---|
37 | { |
---|
38 | GB_transaction ta(gb_main); |
---|
39 | GB_tell_server_dont_wait(gb_main); // trigger database callbacks |
---|
40 | } |
---|
41 | aw_root->add_timed_callback(500, DI_timer, cl_gbmain, cd2); |
---|
42 | } |
---|
43 | |
---|
44 | int ARB_main(int argc, const char *argv[]) { |
---|
45 | if (argc >= 2 && strcmp(argv[1], "--help") == 0) { |
---|
46 | fprintf(stderr, |
---|
47 | "Usage: arb_dist\n" |
---|
48 | "Is called from ARB.\n" |
---|
49 | ); |
---|
50 | exit(-1); |
---|
51 | } |
---|
52 | |
---|
53 | aw_initstatus(); |
---|
54 | |
---|
55 | GB_shell shell; |
---|
56 | AW_root *aw_root = AWT_create_root("dist.arb", "ARB_DIST"); |
---|
57 | |
---|
58 | { |
---|
59 | arb_params *params = arb_trace_argv(&argc, (const char **)argv); |
---|
60 | if (argc==2) { |
---|
61 | freedup(params->db_server, argv[1]); |
---|
62 | } |
---|
63 | GLOBAL_gb_main = GB_open(params->db_server, "rw"); |
---|
64 | if (!GLOBAL_gb_main) { |
---|
65 | aw_message(GB_await_error()); |
---|
66 | exit(-1); |
---|
67 | } |
---|
68 | |
---|
69 | #if defined(DEBUG) |
---|
70 | AWT_announce_db_to_browser(GLOBAL_gb_main, GBS_global_string("ARB-database (%s)", params->db_server)); |
---|
71 | #endif // DEBUG |
---|
72 | |
---|
73 | free_arb_params(params); |
---|
74 | } |
---|
75 | |
---|
76 | DI_create_matrix_variables(aw_root, AW_ROOT_DEFAULT, GLOBAL_gb_main); |
---|
77 | #ifdef FINDCORR |
---|
78 | bc_create_bc_variables(aw_root, AW_ROOT_DEFAULT); |
---|
79 | #endif |
---|
80 | ARB_init_global_awars(aw_root, AW_ROOT_DEFAULT, GLOBAL_gb_main); |
---|
81 | |
---|
82 | AW_window *aww = DI_create_matrix_window(aw_root); |
---|
83 | aww->show(); |
---|
84 | |
---|
85 | AWT_install_cb_guards(); |
---|
86 | |
---|
87 | aw_root->add_timed_callback(2000, DI_timer, AW_CL(GLOBAL_gb_main), 0); |
---|
88 | aw_root->main_loop(); |
---|
89 | |
---|
90 | return EXIT_SUCCESS; |
---|
91 | } |
---|
92 | |
---|