ARB
dbconn.cxx
Go to the documentation of this file.
1 // ============================================================== //
2 // //
3 // File : dbconn.cxx //
4 // Purpose : Connector to running ARB //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in August 2011 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ============================================================== //
11 
12 #include "dbconn.h"
13 #include <arbdb.h>
14 
15 class ARBDB_connector : virtual Noncopyable {
16  GB_shell shell;
17  GBDATA *gb_main;
18 
19 public:
21  gb_main = GB_open(":", "rwt");
22  if (!gb_main) {
24  exit(EXIT_FAILURE);
25  }
26  }
28  GB_close(gb_main);
29  }
30 
31  GBDATA *main() const { return gb_main; }
32 };
33 
34 
36  static SmartPtr<ARBDB_connector> db;
37  if (db.isNull()) db = new ARBDB_connector;
38  return db->main();
39 }
40 
GBDATA * GB_open(const char *path, const char *opent)
Definition: ad_load.cxx:1363
bool isNull() const
test if SmartPtr is NULp
Definition: smartptr.h:248
Generic smart pointer.
Definition: smartptr.h:149
#define EXIT_FAILURE
Definition: arb_a2ps.c:157
GB_ERROR GB_print_error()
Definition: arb_msg.cxx:335
GBDATA * main() const
Definition: dbconn.cxx:31
GBDATA * runningDatabase()
Definition: dbconn.cxx:35
void GB_close(GBDATA *gbd)
Definition: arbdb.cxx:625