source: branches/profile/ARBDB/gb_localdata.h

Last change on this file was 11888, checked in by westram, 10 years ago
  • highlight differences in production code triggered by build-flag 'UNIT_TESTS'
File size: 2.2 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : gb_localdata.h                                    //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef GB_LOCALDATA_H
12#define GB_LOCALDATA_H
13
14#ifndef _GLIBCXX_CSTDDEF
15#include <cstddef>
16#endif
17#ifndef ARBTOOLS_H
18#include <arbtools.h>
19#endif
20
21struct GBDATA;
22struct GB_MAIN_TYPE;
23struct gb_compress_tree;
24struct gb_compress_list;
25
26struct gb_buffer {
27    char   *mem;
28    size_t  size;
29};
30
31enum ARB_TRANS_TYPE {
32    ARB_COMMIT,
33    ARB_ABORT,
34    ARB_TRANS,
35    ARB_NO_TRANS
36};
37
38struct gb_exitfun;
39
40class gb_local_data : virtual Noncopyable {
41    // global data structure used for all open databases
42    // @@@ could be moved into GB_shell
43
44    GB_MAIN_TYPE **open_gb_mains;
45    int            open_gb_alloc;
46
47    int openedDBs;
48    int closedDBs;
49
50public:
51    gb_buffer  buf1, buf2;
52    char      *write_buffer;
53    char      *write_ptr;
54    long       write_bufsize;
55    long       write_free;
56    bool       iamclient;
57    bool       search_system_folder;
58
59    gb_compress_tree *bituncompress;
60    gb_compress_list *bitcompress;
61
62    long bc_size;
63
64    ARB_TRANS_TYPE  running_client_transaction;
65    struct gbl_ {
66        GBDATA *gb_main;
67        gbl_() : gb_main(0) {}
68    } gbl;
69
70    gb_exitfun *atgbexit;
71
72    gb_local_data();
73    ~gb_local_data();
74
75    int open_dbs() const { return openedDBs-closedDBs; }
76   
77    void announce_db_open(GB_MAIN_TYPE *Main);
78    void announce_db_close(GB_MAIN_TYPE *Main);
79    GB_MAIN_TYPE *get_any_open_db() { int idx = open_dbs(); return idx ? open_gb_mains[idx-1] : NULL; }
80
81#if defined(UNIT_TESTS) // UT_DIFF
82    void fake_closed_DBs() {
83        closedDBs = openedDBs;
84    }
85#endif
86};
87
88extern gb_local_data *gb_local;
89
90#else
91#error gb_localdata.h included twice
92#endif // GB_LOCALDATA_H
93
Note: See TracBrowser for help on using the repository browser.