source: branches/profile/ARBDB/gb_header.h

Last change on this file was 9838, checked in by westram, 11 years ago
  • reintegrated branch 'db'
    • GBDATA now is a base class of GBENTRY (new) and GBCONTAINER
      • moved code into classes GBENTRY, GBCONTAINER and GB_MAIN_TYPE
      • several functions now exist 2 (or 3) times (for GBENTRY and GBCONTAINER, and some for GBDATA as well)
      • several functions changed their interface (caller has to explicitely pass GBENTRY or GBCONTAINER)
    • dropped support for ARB DB-version 0
  • adds:
File size: 2.3 KB
Line 
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
19struct 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
34struct 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
42inline GBDATA *GB_HEADER_LIST_GBD(gb_header_list& hl) {
43    return GB_RESOLVE(GBDATA*, (&(hl)), rel_hl_gbd);
44}
45inline void SET_GB_HEADER_LIST_GBD(gb_header_list& hl, GBDATA *gbd) {
46    GB_SETREL(&hl, rel_hl_gbd, gbd);
47}
48
49inline 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
54inline GBDATA *EXISTING_GBCONTAINER_ELEM(GBCONTAINER *gbc, int idx) {
55    return GB_HEADER_LIST_GBD(GB_DATA_LIST_HEADER((gbc)->d)[idx]);
56}
57inline GBDATA *GBCONTAINER_ELEM(GBCONTAINER *gbc, int idx) {
58    return (idx<gbc->d.nheader) ? EXISTING_GBCONTAINER_ELEM(gbc, idx) : (GBDATA*)NULL;
59}
60inline 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
Note: See TracBrowser for help on using the repository browser.