1 | // ============================================================ // |
---|
2 | // // |
---|
3 | // File : db_query_local.h // |
---|
4 | // Purpose : internal query defs // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // ============================================================ // |
---|
10 | |
---|
11 | #ifndef DB_QUERY_LOCAL_H |
---|
12 | #define DB_QUERY_LOCAL_H |
---|
13 | |
---|
14 | #ifndef ARBDBT_H |
---|
15 | #include <arbdbt.h> |
---|
16 | #endif |
---|
17 | |
---|
18 | #define dbq_assert(cond) arb_assert(cond) |
---|
19 | |
---|
20 | class Itemfield_Selection; |
---|
21 | |
---|
22 | namespace QUERY { |
---|
23 | |
---|
24 | enum QUERY_MODES { |
---|
25 | QUERY_GENERATE, |
---|
26 | QUERY_ENLARGE, |
---|
27 | QUERY_REDUCE |
---|
28 | }; |
---|
29 | |
---|
30 | enum QUERY_TYPES { |
---|
31 | QUERY_MARKED, |
---|
32 | QUERY_MATCH, |
---|
33 | QUERY_DONT_MATCH |
---|
34 | }; |
---|
35 | |
---|
36 | #define QUERY_SEARCHES 3 // no of search-lines in search tool |
---|
37 | |
---|
38 | #define QUERY_SORT_CRITERIA_BITS 6 // number of "real" sort criteria |
---|
39 | #define QUERY_SORT_CRITERIA_MASK ((1<<QUERY_SORT_CRITERIA_BITS)-1) |
---|
40 | |
---|
41 | enum QUERY_RESULT_ORDER { |
---|
42 | QUERY_SORT_NONE = 0, |
---|
43 | |
---|
44 | // "real" criteria: |
---|
45 | QUERY_SORT_BY_1STFIELD_CONTENT = 1, // by content of first selected search field |
---|
46 | QUERY_SORT_BY_ID = 2, // by item id (not by parent) |
---|
47 | QUERY_SORT_BY_NESTED_PID = 4, // by nested parent id |
---|
48 | QUERY_SORT_BY_MARKED = 8, // marked items first |
---|
49 | QUERY_SORT_BY_HIT_DESCRIPTION = 16, // by hit description |
---|
50 | QUERY_SORT_REVERSE = 32, // revert following (may occur multiple times) |
---|
51 | |
---|
52 | }; |
---|
53 | |
---|
54 | class DbQuery : virtual Noncopyable { |
---|
55 | AwarName awar_tree_name; |
---|
56 | |
---|
57 | public: |
---|
58 | AW_window *aws; |
---|
59 | GBDATA *gb_main; // the main database (in merge tool: source db in left query; dest db in right query) |
---|
60 | GBDATA *gb_ref; // second reference database (only used by merge tool; dest db in left query; source db in right query) |
---|
61 | bool expect_hit_in_ref_list; // merge-tool: when searching dups in fields: match only if hit exists in other DBs hitlist (true for target-DB-query) |
---|
62 | |
---|
63 | char *awar_keys[QUERY_SEARCHES]; |
---|
64 | char *awar_queries[QUERY_SEARCHES]; |
---|
65 | char *awar_not[QUERY_SEARCHES]; // not flags for queries |
---|
66 | char *awar_operator[QUERY_SEARCHES]; // not flags for queries |
---|
67 | |
---|
68 | char *species_name; |
---|
69 | |
---|
70 | char *awar_setkey; |
---|
71 | char *awar_setprotection; |
---|
72 | char *awar_setvalue; |
---|
73 | |
---|
74 | char *awar_parskey; |
---|
75 | char *awar_parsvalue; |
---|
76 | char *awar_parspredefined; |
---|
77 | char *awar_createDestField; |
---|
78 | char *awar_acceptConvError; |
---|
79 | |
---|
80 | char *awar_ere; |
---|
81 | char *awar_where; |
---|
82 | char *awar_by; |
---|
83 | char *awar_use_tag; |
---|
84 | char *awar_double_pars; |
---|
85 | char *awar_deftag; |
---|
86 | char *awar_tag; |
---|
87 | char *awar_count; |
---|
88 | char *awar_sort; |
---|
89 | |
---|
90 | unsigned long sort_mask; // contains several cascading sort criteria (QUERY_SORT_CRITERIA_BITS each) |
---|
91 | |
---|
92 | AW_selection_list *hitlist; |
---|
93 | Itemfield_Selection *fieldsel[QUERY_SEARCHES]; |
---|
94 | |
---|
95 | ItemSelector& selector; |
---|
96 | int select_bit; // one of 1 2 4 8 .. 128 (one for each query box) |
---|
97 | GB_HASH *hit_description; // key = char* (hit item name), value = char* (description of hit - allocated!) |
---|
98 | |
---|
99 | DbQuery(ItemSelector& selector_) |
---|
100 | : selector(selector_) |
---|
101 | { |
---|
102 | dbq_assert(&selector); |
---|
103 | } |
---|
104 | ~DbQuery(); |
---|
105 | |
---|
106 | bool is_queried(GBDATA *gb_item) const { |
---|
107 | return GB_user_flag(gb_item, select_bit); |
---|
108 | } |
---|
109 | |
---|
110 | const char *get_tree_name() const; |
---|
111 | void set_tree_awar_name(const char *tree_awar_name) { // @@@ intermediate - should be set by ctor |
---|
112 | awar_tree_name = tree_awar_name; |
---|
113 | } |
---|
114 | }; |
---|
115 | |
---|
116 | }; |
---|
117 | #else |
---|
118 | #error db_query_local.h included twice |
---|
119 | #endif // DB_QUERY_LOCAL_H |
---|
120 | |
---|