Line | |
---|
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: |
---|
20 | ARBDB_connector() { |
---|
21 | gb_main = GB_open(":", "rwt"); |
---|
22 | if (!gb_main) { |
---|
23 | GB_print_error(); |
---|
24 | exit(EXIT_FAILURE); |
---|
25 | } |
---|
26 | } |
---|
27 | ~ARBDB_connector() { |
---|
28 | GB_close(gb_main); |
---|
29 | } |
---|
30 | |
---|
31 | GBDATA *main() const { return gb_main; } |
---|
32 | }; |
---|
33 | |
---|
34 | |
---|
35 | GBDATA *runningDatabase() { |
---|
36 | static SmartPtr<ARBDB_connector> db; |
---|
37 | if (db.isNull()) db = new ARBDB_connector; |
---|
38 | return db->main(); |
---|
39 | } |
---|
40 | |
---|
Note: See
TracBrowser
for help on using the repository browser.