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