source: tags/svn.1.5.4/ARBDB/arbdb.h

Last change on this file was 8253, checked in by westram, 14 years ago
  • fixed some global shadow warnings
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1// ================================================================ //
2//                                                                  //
3//   File      : arbdb.h                                            //
4//   Purpose   : external ARB DB interface                          //
5//                                                                  //
6//   Institute of Microbiology (Technical University Munich)        //
7//   http://www.arb-home.de/                                        //
8//                                                                  //
9// ================================================================ //
10
11#ifndef ARBDB_H
12#define ARBDB_H
13
14#ifndef ARBTOOLS_H
15#include <arbtools.h>
16#endif
17#ifndef ARBDB_BASE_H
18#include <arbdb_base.h>
19#endif
20#ifndef ARB_ERROR_H
21#include <arb_error.h>
22#endif
23#ifndef _STDINT_H
24#include <stdint.h>
25#endif
26
27// ---------------------
28//      simple types
29
30typedef int GB_COMPRESSION_MASK;
31
32// ------------------------------
33//      forward declare types
34
35struct GB_NUMHASH;
36
37struct GBS_regex;
38struct GBS_string_matcher;
39struct GBS_strstruct;
40struct GEN_position;
41struct DictData;
42struct CharPtrArray;
43struct StrArray;
44struct ConstStrArray;
45
46// --------------
47//      enums
48
49enum GB_TYPES {                                     // supported DB entry types
50    GB_NONE        = 0,
51    GB_BIT         = 1,
52    GB_BYTE        = 2,
53    GB_INT         = 3,
54    GB_FLOAT       = 4,
55    GB_POINTER     = 5,                             // not savable! only allowed in temporary entries
56    GB_BITS        = 6,
57    // 7 is unused
58    GB_BYTES       = 8,
59    GB_INTS        = 9,
60    GB_FLOATS      = 10,
61    GB_LINK        = 11,
62    GB_STRING      = 12,
63    GB_STRING_SHRT = 13,                            // used automatically during save
64    // 14 is unused
65    GB_DB          = 15,
66
67    // keep GB_TYPES consistent with AW_VARIABLE_TYPE
68    // see ../WINDOW/aw_base.hxx@sync_GB_TYPES_AW_VARIABLE_TYPE
69
70    GB_TYPE_MAX = 16,
71
72    GB_CREATE_CONTAINER = GB_DB,
73    GB_FIND             = GB_NONE,
74
75};
76
77enum GB_CASE {
78    GB_IGNORE_CASE    = 0,
79    GB_MIND_CASE      = 1,
80    GB_CASE_UNDEFINED = 2
81};
82
83enum GB_SEARCH_TYPE {
84    SEARCH_BROTHER       = 1,                       // [was: this_level]
85    SEARCH_CHILD         = 2,                       // [was: down_level]
86    SEARCH_GRANDCHILD    = 4,                       // [was: down_2_level]
87    SEARCH_NEXT_BROTHER  = SEARCH_BROTHER+8,        // [was: this_level|search_next]
88    SEARCH_CHILD_OF_NEXT = SEARCH_CHILD+8,          // [was: down_level|search_next]
89};
90
91enum GB_UNDO_TYPE {
92    GB_UNDO_NONE,                                   // no undo
93    GB_UNDO_KILL,                                   // no undo and delete all old undos
94    GB_UNDO_UNDO,                                   // normal undo -> deleted all redoes
95    GB_UNDO_REDO,                                   // moves to UNDO_REDO
96    GB_UNDO_UNDO_REDO                               // internal makes undo redoable
97};
98
99
100// -----------------------
101//      callback types
102
103typedef void (*GB_CB)(GBDATA *, int *clientdata, GB_CB_TYPE gbtype);
104
105typedef long (*gb_hash_loop_type)(const char *key, long val, void *client_data);
106typedef int (*gbs_hash_compare_function) (const char *key0, long val0, const char *key1, long val1);
107
108typedef const char* (*gb_export_sequence_cb)(GBDATA *gb_species, size_t *seq_len, GB_ERROR *error);
109
110typedef GBDATA* (*GB_Link_Follower)(GBDATA *GB_root, GBDATA *GB_elem, const char *link);
111
112typedef const char *(*gb_getenv_hook)(const char *varname);
113
114// -----------------------
115//      GB_transaction
116
117class GB_transaction : virtual Noncopyable {
118    GBDATA *ta_main;
119    bool      ta_open;          // is transaction open ?
120    GB_ERROR  ta_err;
121
122public:
123    GB_transaction(GBDATA *gb_main);
124    ~GB_transaction();
125
126    bool ok() const { return ta_open && !ta_err; }  // ready to work on DB?
127    GB_ERROR close(GB_ERROR error);                 // abort transaction if error (e.g.: 'return ta.close(error);')
128    ARB_ERROR close(ARB_ERROR& error);              // abort transaction if error (e.g.: 'return ta.close(error);')
129};
130
131class GB_shell {
132    // initialize and cleanup module ARBDB
133    // No database usage is possible when no GB_shell exists!
134public: 
135    GB_shell();
136    ~GB_shell();
137
138    static void ensure_inside();
139    static bool in_shell();
140};
141
142// --------------------------------------------
143//      include generated public prototypes
144
145#include <ad_prot.h>
146
147// to avoid arb-wide changes atm include some headers from CORE lib
148#ifndef ARB_MSG_H
149#include <arb_msg.h>
150#endif
151#ifndef ARB_STRING_H
152#include <arb_string.h>
153#endif
154
155// ----------------------------------------------------
156//      const wrappers for functions from ad_prot.h
157
158inline char *GBS_find_string(char *content, GB_CSTR key, int match_mode) {
159    return const_cast<char*>(GBS_find_string(const_cast<GB_CSTR>(content), key, match_mode));
160}
161
162// ---------------------------------
163//      error delivery functions
164
165inline void GB_end_transaction_show_error(GBDATA *gbd, ARB_ERROR& error, void (*error_handler)(GB_ERROR)) {
166    GB_end_transaction_show_error(gbd, error.deliver(), error_handler);
167}
168inline ARB_ERROR GB_end_transaction(GBDATA *gbd, ARB_ERROR& error) {
169    return GB_end_transaction(gbd, error.deliver());
170}
171
172
173#else
174#error arbdb.h included twice
175#endif // ARBDB_H
Note: See TracBrowser for help on using the repository browser.