1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : gb_header.h // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #ifndef GB_HEADER_H |
---|
12 | #define GB_HEADER_H |
---|
13 | |
---|
14 | #ifndef GB_DATA_H |
---|
15 | #include "gb_data.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | |
---|
19 | struct gb_header_flags { |
---|
20 | unsigned int flags : GB_MAX_USERS; // public |
---|
21 | unsigned int key_quark : 24; // == 0 -> invalid |
---|
22 | unsigned int changed : 3; |
---|
23 | unsigned int ever_changed : 1; // is this element ever changed |
---|
24 | |
---|
25 | void set_change(GB_CHANGE val) { |
---|
26 | changed = val; |
---|
27 | ever_changed = 1; |
---|
28 | } |
---|
29 | void inc_change(GB_CHANGE val) { |
---|
30 | if (changed<unsigned(val)) set_change(val); |
---|
31 | } |
---|
32 | }; |
---|
33 | |
---|
34 | struct gb_header_list { // public fast flags |
---|
35 | gb_header_flags flags; |
---|
36 | GB_REL_GBDATA rel_hl_gbd; |
---|
37 | /* pointer to data |
---|
38 | if 0 & !key_index -> free data |
---|
39 | if 0 & key_index -> data only in server */ |
---|
40 | }; |
---|
41 | |
---|
42 | inline GBDATA *GB_HEADER_LIST_GBD(gb_header_list& hl) { |
---|
43 | return GB_RESOLVE(GBDATA*, (&(hl)), rel_hl_gbd); |
---|
44 | } |
---|
45 | inline void SET_GB_HEADER_LIST_GBD(gb_header_list& hl, GBDATA *gbd) { |
---|
46 | GB_SETREL(&hl, rel_hl_gbd, gbd); |
---|
47 | } |
---|
48 | |
---|
49 | inline gb_header_flags& GB_ARRAY_FLAGS(GBDATA *gbd) { return GB_DATA_LIST_HEADER(GB_FATHER(gbd)->d)[gbd->index].flags; } |
---|
50 | |
---|
51 | // --------------------------------- |
---|
52 | // container element access |
---|
53 | |
---|
54 | inline GBDATA *EXISTING_GBCONTAINER_ELEM(GBCONTAINER *gbc, int idx) { |
---|
55 | return GB_HEADER_LIST_GBD(GB_DATA_LIST_HEADER((gbc)->d)[idx]); |
---|
56 | } |
---|
57 | inline GBDATA *GBCONTAINER_ELEM(GBCONTAINER *gbc, int idx) { |
---|
58 | return (idx<gbc->d.nheader) ? EXISTING_GBCONTAINER_ELEM(gbc, idx) : NULp; |
---|
59 | } |
---|
60 | inline void SET_GBCONTAINER_ELEM(GBCONTAINER *gbc, int idx, GBDATA *gbd) { |
---|
61 | SET_GB_HEADER_LIST_GBD(GB_DATA_LIST_HEADER(gbc->d)[idx], gbd); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | #else |
---|
66 | #error gb_header.h included twice |
---|
67 | #endif // GB_HEADER_H |
---|