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 
26 
27 static unsigned DI_timer(AW_root*, GBDATA *gb_main) {
28  {
29  GB_transaction ta(gb_main);
30  GB_tell_server_dont_wait(gb_main); // trigger database callbacks
31  }
32  return 500; // recall after 500 ms
33 }
34 
35 int ARB_main(int argc, char *argv[]) {
36  aw_initstatus();
37 
38  GB_shell shell;
39  AW_root *aw_root = AWT_create_root("dist.arb", "ARB_DIST", need_macro_ability());
40 
41  if (argc >= 2 && strcmp(argv[1], "--help") == 0) {
42  fprintf(stderr,
43  "Usage: arb_dist\n"
44  "Is called from ARB.\n"
45  );
46  exit(EXIT_FAILURE);
47  }
48 
50  GBDATA *gb_main = NULp;
51  {
52  arb_params *params = arb_trace_argv(&argc, (const char **)argv);
53  if (argc==2) {
54  freedup(params->db_server, argv[1]);
55  }
56  gb_main = GB_open(params->db_server, "rw");
57  if (!gb_main) {
58  error = GB_await_error();
59  }
60  else {
61  error = configure_macro_recording(aw_root, "ARB_DIST", gb_main);
62 
63 #if defined(DEBUG)
64  if (!error) AWT_announce_db_to_browser(gb_main, GBS_global_string("ARB-database (%s)", params->db_server));
65 #endif // DEBUG
66  }
67  free_arb_params(params);
68  }
69 
70  if (!error) {
71  ARB_init_global_awars(aw_root, AW_ROOT_DEFAULT, gb_main);
72  AWT_initTreeAwarRegistry(gb_main);
73  error = DI_create_matrix_variables(aw_root, AW_ROOT_DEFAULT, gb_main);
74  }
75  if (!error) {
76  AW_window *aww = DI_create_matrix_window(aw_root, gb_main);
77  aww->show();
78 
80 
81  aw_root->add_timed_callback(2000, makeTimedCallback(DI_timer, gb_main));
82  aw_root->main_loop();
83  }
84 
85  if (error) aw_popup_exit(error);
86  return EXIT_SUCCESS;
87 }
88 
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
AW_HEADER_MAIN AW_window * DI_create_matrix_window(AW_root *aw_root, GBDATA *gb_main)
Definition: DI_matr.cxx:1605
GB_ERROR GB_tell_server_dont_wait(GBDATA *gbd)
Definition: adcomm.cxx:1867
int ARB_main(int argc, char *argv[])
Definition: DI_main.cxx:35
void aw_initstatus()
Definition: AW_status.cxx:966
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
GB_ERROR DI_create_matrix_variables(AW_root *aw_root, AW_default aw_def, AW_default db)
Definition: DI_matr.cxx:196
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:459
char * db_server
Definition: servercntrl.h:26
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:342
void show()
Definition: AW_window.cxx:1683
static void error(const char *msg)
Definition: mkptypes.cxx:96
UserActionTracker * need_macro_ability()
Definition: trackers.cxx:455
static unsigned DI_timer(AW_root *, GBDATA *gb_main)
Definition: DI_main.cxx:27
#define EXIT_FAILURE
Definition: arb_a2ps.c:157
#define AW_HEADER_MAIN
Definition: aw_window.hxx:36
void main_loop()
Definition: AW_root.cxx:625
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker)
__ATTR__NORETURN void aw_popup_exit(const char *msg)
#define NULp
Definition: cxxforward.h:116
void AWT_install_cb_guards()
GB_transaction ta(gb_var)
GBDATA * gb_main
Definition: adname.cxx:32
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
void AWT_initTreeAwarRegistry(GBDATA *gbmain)