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

Last change on this file was 6656, checked in by westram, 15 years ago
  • removed unneeded 'struct' keyword
  • renamed several structs (especially things like 'blabla_struct')
File size: 7.1 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : gb_data.h                                         //
4//   Purpose   : GBDATA/GBCONTAINER                                //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef GB_DATA_H
12#define GB_DATA_H
13
14#ifndef GB_LOCAL_H
15#include "gb_local.h"
16#endif
17#ifndef GB_MEMORY_H
18#include "gb_memory.h"
19#endif
20
21
22// --------------------------------------------------------------------------------
23
24#define SIZOFINTERN 10
25
26struct gb_extern_data {
27    GB_REL_STRING rel_data;
28    long          memsize;
29    long          size;
30};
31
32struct GB_INTern_strings {
33    char          data[SIZOFINTERN];
34    unsigned char memsize;
35    unsigned char size;
36};
37
38struct GB_INTern {
39    char data[SIZOFINTERN];
40};
41
42union gb_data_base_type_union {
43    int32_t            i;
44    void              *ptr;
45    GB_INTern_strings  istr;
46    GB_INTern          in;
47    gb_extern_data     ex;
48};
49
50// --------------------------------------------------------------------------------
51
52struct gb_callback {
53    gb_callback *next;
54    GB_CB        func;
55    GB_CB_TYPE   type;
56    int         *clientdata;
57    short        priority;
58    short        running;
59};
60
61// --------------------------------------------------------------------------------
62
63struct gb_db_extended {
64    long                 creation_date;
65    long                 update_date;
66    gb_callback         *callback;
67    gb_transaction_save *old;
68};
69
70// --------------------------------------------------------------------------------
71
72struct gb_flag_types {                                                  // public flags
73    unsigned int type : 4;
74    unsigned int security_delete : 3;
75    unsigned int security_write : 3;
76    unsigned int security_read : 3;
77    unsigned int compressed_data : 1;
78    unsigned int unused : 1;                                            // last bit saved!
79    unsigned int user_flags : 8;
80    unsigned int temporary : 1;                                         // ==1 -> don't save entry
81    unsigned int saved_flags : 8;
82};
83
84struct gb_flag_types2 {                                                 // private flags, abortable
85    // uncritical section, undoable
86    unsigned int last_updated : 8;
87    unsigned int usr_ref : 7;                                           // for user access
88    // critic section, do not update any below
89    unsigned int folded_container : 1;
90    unsigned int update_in_server : 1;                                  // already informed
91    unsigned int extern_data : 1;                                       // data ref. by pntr
92    unsigned int header_changed : 1;                                    // used by container
93    unsigned int gbm_index : 8;                                         // memory section
94    unsigned int tisa_index : 1;                                        // this should be indexed
95    unsigned int is_indexed : 1;                                        // this db. field is indexed
96};
97
98struct gb_flag_types3 {                                                 // user and project flags (public); not abortable !!!
99    unsigned int project : 8;
100    unsigned int unused : 24;
101};
102
103// --------------------------------------------------------------------------------
104
105struct gb_data_list {
106    GB_REL_HLS rel_header;
107    int        headermemsize;
108    int        size;                                                    // number of valid items
109    int        nheader;                                                 // size + deleted items
110};
111
112inline gb_header_list *GB_DATA_LIST_HEADER(gb_data_list& dl) {
113    return GB_RESOLVE(gb_header_list *, (&(dl)), rel_header);
114}
115inline void SET_GB_DATA_LIST_HEADER(gb_data_list& dl, gb_header_list *head) {
116    GB_SETREL(&dl, rel_header, head);
117}
118
119// --------------------------------------------------------------------------------
120
121struct GBDATA {
122    long              server_id;
123    GB_REL_CONTAINER  rel_father;
124    gb_db_extended   *ext;
125    long              index;
126    gb_flag_types     flags;
127    gb_flag_types2    flags2;
128    // member above are same as in GBCONTAINER
129
130    gb_data_base_type_union info;
131    int                     cache_index;                                // @@@ should be a member of gb_db_extended and of type gb_cache_idx
132};
133
134struct GBCONTAINER {
135    long              server_id;
136    GB_REL_CONTAINER  rel_father;
137    gb_db_extended   *ext;
138    long              index;
139    gb_flag_types     flags;
140    gb_flag_types2    flags2;
141    // member above are same as in GBDATA
142
143    gb_flag_types3 flags3;
144    gb_data_list   d;
145
146    long index_of_touched_one_son;  /* index of modified son
147                                     * in case of a single mod. son
148                                     * -1 more than one (or one with ind = 0)
149                                     *  0    no son
150                                     * >0   index */
151    long header_update_date;
152
153    GB_MAIN_IDX main_idx;
154    GB_REL_IFS  rel_ifs;
155
156};
157
158// --------------------
159//      type access
160
161inline GB_TYPES GB_TYPE(GBDATA *gbd)      { return GB_TYPES(gbd->flags.type); }
162inline GB_TYPES GB_TYPE(GBCONTAINER *gbc) { return GB_TYPES(gbc->flags.type); }
163
164// ----------------------
165//      parent access
166
167inline GBCONTAINER* GB_FATHER(GBDATA *gbd)                       { return GB_RESOLVE(GBCONTAINER*, gbd, rel_father); }
168inline GBCONTAINER* GB_FATHER(GBCONTAINER *gbc)                  { return GB_RESOLVE(GBCONTAINER*, gbc, rel_father); }
169inline void SET_GB_FATHER(GBDATA *gbd, GBCONTAINER *father)      { GB_SETREL(gbd, rel_father, father); }
170inline void SET_GB_FATHER(GBCONTAINER *gbc, GBCONTAINER *father) { GB_SETREL(gbc, rel_father, father); }
171inline GBCONTAINER* GB_GRANDPA(GBDATA *gbd)                      { return GB_FATHER(GB_FATHER(gbd)); }
172
173// -----------------------
174//      GB_MAIN access
175
176extern GB_MAIN_TYPE *gb_main_array[];
177
178inline GB_MAIN_TYPE *GBCONTAINER_MAIN(GBCONTAINER *gbc) { return gb_main_array[gbc->main_idx]; }
179inline GB_MAIN_TYPE *GB_MAIN(GBDATA *gbd)               { return GBCONTAINER_MAIN(GB_FATHER(gbd)); }
180inline GB_MAIN_TYPE *GB_MAIN(GBCONTAINER *gbc)          { return GBCONTAINER_MAIN(gbc); }
181inline GB_MAIN_TYPE *GB_MAIN_NO_FATHER(GBDATA *gbd)     { return GB_TYPE(gbd) == GB_DB ? GBCONTAINER_MAIN((GBCONTAINER*)gbd) : GB_MAIN(gbd); }
182
183// -----------------------
184//      security flags
185
186#define GB_GET_SECURITY_READ(gb)   ((gb)->flags.security_read)
187#define GB_GET_SECURITY_WRITE(gb)  ((gb)->flags.security_write)
188#define GB_GET_SECURITY_DELETE(gb) ((gb)->flags.security_delete)
189
190#define GB_PUT_SECURITY_READ(gb, i)  ((gb)->flags.security_read   = (i))
191#define GB_PUT_SECURITY_WRITE(gb, i) ((gb)->flags.security_write  = (i))
192#define GB_PUT_SECURITY_DELETE(gb, i) ((gb)->flags.security_delete = (i))
193
194// --------------------------------------------------------------------------------
195
196#else
197#error gb_data.h included twice
198#endif // GB_DATA_H
Note: See TracBrowser for help on using the repository browser.