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 | #include <servercntrl.h> |
---|
12 | #include <arbdb.h> |
---|
13 | #include <awt.hxx> |
---|
14 | |
---|
15 | #include <aw_preset.hxx> |
---|
16 | #include <aw_root.hxx> |
---|
17 | #include <macros.hxx> |
---|
18 | #include <aw_question.hxx> |
---|
19 | #include <awt_TreeAwars.hxx> |
---|
20 | |
---|
21 | |
---|
22 | AW_HEADER_MAIN |
---|
23 | |
---|
24 | AW_window *DI_create_matrix_window(AW_root *aw_root); |
---|
25 | void DI_create_matrix_variables(AW_root *aw_root, AW_default aw_def, AW_default db); |
---|
26 | |
---|
27 | GBDATA *GLOBAL_gb_main; // global gb_main for arb_dist |
---|
28 | |
---|
29 | |
---|
30 | static unsigned DI_timer(AW_root*, GBDATA *gb_main) { |
---|
31 | { |
---|
32 | GB_transaction ta(gb_main); |
---|
33 | GB_tell_server_dont_wait(gb_main); // trigger database callbacks |
---|
34 | } |
---|
35 | return 500; // recall after 500 ms |
---|
36 | } |
---|
37 | |
---|
38 | int ARB_main(int argc, char *argv[]) { |
---|
39 | aw_initstatus(); |
---|
40 | |
---|
41 | GB_shell shell; |
---|
42 | AW_root *aw_root = AWT_create_root("dist.arb", "ARB_DIST", need_macro_ability(), &argc, &argv); |
---|
43 | |
---|
44 | if (argc >= 2 && strcmp(argv[1], "--help") == 0) { |
---|
45 | fprintf(stderr, |
---|
46 | "Usage: arb_dist\n" |
---|
47 | "Is called from ARB.\n" |
---|
48 | ); |
---|
49 | exit(EXIT_FAILURE); |
---|
50 | } |
---|
51 | |
---|
52 | GB_ERROR error = NULp; |
---|
53 | { |
---|
54 | arb_params *params = arb_trace_argv(&argc, (const char **)argv); |
---|
55 | if (argc==2) { |
---|
56 | freedup(params->db_server, argv[1]); |
---|
57 | } |
---|
58 | GLOBAL_gb_main = GB_open(params->db_server, "rw"); |
---|
59 | if (!GLOBAL_gb_main) { |
---|
60 | error = GB_await_error(); |
---|
61 | } |
---|
62 | else { |
---|
63 | error = configure_macro_recording(aw_root, "ARB_DIST", GLOBAL_gb_main); |
---|
64 | |
---|
65 | #if defined(DEBUG) |
---|
66 | if (!error) AWT_announce_db_to_browser(GLOBAL_gb_main, GBS_global_string("ARB-database (%s)", params->db_server)); |
---|
67 | #endif // DEBUG |
---|
68 | } |
---|
69 | free_arb_params(params); |
---|
70 | } |
---|
71 | |
---|
72 | if (!error) { |
---|
73 | ARB_init_global_awars(aw_root, AW_ROOT_DEFAULT, GLOBAL_gb_main); |
---|
74 | AWT_initTreeAwarRegistry(GLOBAL_gb_main); |
---|
75 | DI_create_matrix_variables(aw_root, AW_ROOT_DEFAULT, GLOBAL_gb_main); |
---|
76 | |
---|
77 | AW_window *aww = DI_create_matrix_window(aw_root); |
---|
78 | aww->show(); |
---|
79 | |
---|
80 | AWT_install_cb_guards(); |
---|
81 | |
---|
82 | aw_root->add_timed_callback(2000, makeTimedCallback(DI_timer, GLOBAL_gb_main)); |
---|
83 | aw_root->main_loop(); |
---|
84 | } |
---|
85 | |
---|
86 | if (error) aw_popup_exit(error); |
---|
87 | return EXIT_SUCCESS; |
---|
88 | } |
---|
89 | |
---|