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 | #ifndef DB_QUERY_H |
---|
18 | #include "db_query.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #define dbq_assert(cond) arb_assert(cond) |
---|
22 | |
---|
23 | class Itemfield_Selection; |
---|
24 | class QueryExpr; |
---|
25 | |
---|
26 | namespace QUERY { |
---|
27 | |
---|
28 | enum QUERY_MODES { |
---|
29 | QUERY_GENERATE, |
---|
30 | QUERY_ENLARGE, |
---|
31 | QUERY_REDUCE |
---|
32 | }; |
---|
33 | |
---|
34 | enum QUERY_TYPES { |
---|
35 | QUERY_MARKED, |
---|
36 | QUERY_MATCH, |
---|
37 | QUERY_DONT_MATCH |
---|
38 | }; |
---|
39 | |
---|
40 | #define QUERY_EXPRESSIONS 3 // no of search-lines in search tool |
---|
41 | |
---|
42 | #define QUERY_SORT_CRITERIA_BITS 7 // number of "real" sort criteria |
---|
43 | #define QUERY_SORT_CRITERIA_MASK ((1<<QUERY_SORT_CRITERIA_BITS)-1) |
---|
44 | |
---|
45 | enum QUERY_RESULT_ORDER { |
---|
46 | QUERY_SORT_NONE = 0, |
---|
47 | |
---|
48 | // "real" criteria (do not change values, will break existing macro-code): |
---|
49 | QUERY_SORT_BY_1STFIELD_CONTENT = 1, // by content of first selected search field |
---|
50 | QUERY_SORT_BY_ID = 2, // by item id (not by parent) |
---|
51 | QUERY_SORT_BY_NESTED_PID = 4, // by nested parent id |
---|
52 | QUERY_SORT_BY_MARKED = 8, // marked items first |
---|
53 | QUERY_SORT_BY_HIT_DESCRIPTION = 16, // by hit description |
---|
54 | QUERY_SORT_REVERSE = 32, // revert following (may occur multiple times) |
---|
55 | QUERY_SORT_NUM_BY_1STFIELD_CONTENT = 64, // by content of first selected search field (numerically) |
---|
56 | |
---|
57 | }; |
---|
58 | |
---|
59 | class DbQuery : virtual Noncopyable { |
---|
60 | AwarName awar_tree_name; |
---|
61 | |
---|
62 | public: |
---|
63 | AW_window *aws; |
---|
64 | GBDATA *gb_main; // the main database (in merge tool: source db in left query; dest db in right query) |
---|
65 | GBDATA *gb_ref; // second reference database (only used by merge tool; dest db in left query; source db in right query) |
---|
66 | 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) |
---|
67 | |
---|
68 | char *awar_keys[QUERY_EXPRESSIONS]; |
---|
69 | char *awar_queries[QUERY_EXPRESSIONS]; |
---|
70 | char *awar_not[QUERY_EXPRESSIONS]; // not flags for queries |
---|
71 | char *awar_operator[QUERY_EXPRESSIONS]; // not flags for queries |
---|
72 | |
---|
73 | char *species_name; |
---|
74 | |
---|
75 | char *awar_writekey; |
---|
76 | char *awar_writelossy; |
---|
77 | |
---|
78 | char *awar_protectkey; |
---|
79 | char *awar_setprotection; |
---|
80 | char *awar_setvalue; |
---|
81 | |
---|
82 | char *awar_parskey; |
---|
83 | char *awar_parsvalue; |
---|
84 | char *awar_parspredefined; |
---|
85 | char *awar_acceptConvError; |
---|
86 | char *awar_acceptIdMod; |
---|
87 | |
---|
88 | char *awar_ere; |
---|
89 | char *awar_where; |
---|
90 | char *awar_by; |
---|
91 | char *awar_use_tag; |
---|
92 | char *awar_double_pars; |
---|
93 | char *awar_deftag; |
---|
94 | char *awar_tag; |
---|
95 | char *awar_count; |
---|
96 | char *awar_sort; |
---|
97 | |
---|
98 | unsigned long sort_mask; // contains several cascading sort criteria (QUERY_SORT_CRITERIA_BITS each) |
---|
99 | |
---|
100 | AW_selection_list *hitlist; |
---|
101 | |
---|
102 | ItemSelector& selector; |
---|
103 | int select_bit; // one of 1 2 4 8 .. 128 (one for each query box) |
---|
104 | GB_HASH *hit_description; // key = char* (hit item name), value = char* (description of hit - allocated!) |
---|
105 | |
---|
106 | DbQuery(ItemSelector& selector_) |
---|
107 | : selector(selector_) |
---|
108 | { |
---|
109 | dbq_assert(&selector); |
---|
110 | } |
---|
111 | ~DbQuery(); |
---|
112 | |
---|
113 | bool is_queried(GBDATA *gb_item) const { |
---|
114 | return GB_user_flag(gb_item, select_bit); |
---|
115 | } |
---|
116 | |
---|
117 | const char *get_tree_name() const; |
---|
118 | void set_tree_awar_name(const char *tree_awar_name) { // @@@ intermediate - should be set by ctor |
---|
119 | awar_tree_name = tree_awar_name; |
---|
120 | } |
---|
121 | |
---|
122 | SmartPtr<QueryExpr> buildQueryExpr(); |
---|
123 | }; |
---|
124 | |
---|
125 | }; |
---|
126 | #else |
---|
127 | #error db_query_local.h included twice |
---|
128 | #endif // DB_QUERY_LOCAL_H |
---|
129 | |
---|
130 | |
---|