ARB
DI_main.cxx
Go to the documentation of this file.
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 
23 
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 
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 
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 
const char * GB_ERROR
Definition: arb_core.h:25
GBDATA * GB_open(const char *path, const char *opent)
Definition: ad_load.cxx:1363
__ATTR__USERESULT_TODO GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main)
Definition: aw_root.hxx:198
GB_ERROR GB_tell_server_dont_wait(GBDATA *gbd)
Definition: adcomm.cxx:1867
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker, int *argc, char ***argv)
int ARB_main(int argc, char *argv[])
Definition: DI_main.cxx:38
void aw_initstatus()
Definition: AW_status.cxx:766
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
void add_timed_callback(int ms, const TimedCallback &tcb)
Definition: AW_root.cxx:538
#define EXIT_SUCCESS
Definition: arb_a2ps.c:154
__ATTR__USERESULT GB_ERROR configure_macro_recording(AW_root *aw_root, const char *client_id, GBDATA *gb_main)
Definition: trackers.cxx:454
char * db_server
Definition: servercntrl.h:26
GBDATA * GLOBAL_gb_main
Definition: DI_main.cxx:27
arb_params * arb_trace_argv(int *argc, const char **argv)
void free_arb_params(arb_params *params)
GB_ERROR GB_await_error()
Definition: arb_msg.cxx:353
void show()
Definition: AW_window.cxx:1658
static void error(const char *msg)
Definition: mkptypes.cxx:96
UserActionTracker * need_macro_ability()
Definition: trackers.cxx:450
void DI_create_matrix_variables(AW_root *aw_root, AW_default aw_def, AW_default db)
Definition: DI_matr.cxx:197
static unsigned DI_timer(AW_root *, GBDATA *gb_main)
Definition: DI_main.cxx:30
#define EXIT_FAILURE
Definition: arb_a2ps.c:157
#define AW_HEADER_MAIN
Definition: aw_window.hxx:36
AW_HEADER_MAIN AW_window * DI_create_matrix_window(AW_root *aw_root)
Definition: DI_matr.cxx:1528
void main_loop()
Definition: AW_root.cxx:625
__ATTR__NORETURN void aw_popup_exit(const char *msg)
#define NULp
Definition: cxxforward.h:97
void AWT_install_cb_guards()
GB_transaction ta(gb_var)
GBDATA * gb_main
Definition: adname.cxx:33
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
void AWT_initTreeAwarRegistry(GBDATA *gbmain)