source: tags/testbuild/SL/ITEMS/items.h

Last change on this file was 12212, checked in by westram, 10 years ago
  • pass down fallback2default to popup_select_species_field_window
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1// ============================================================ //
2//                                                              //
3//   File      : items.h                                        //
4//   Purpose   :                                                //
5//                                                              //
6//   Institute of Microbiology (Technical University Munich)    //
7//   http://www.arb-home.de/                                    //
8//                                                              //
9// ============================================================ //
10
11#ifndef ITEMS_H
12#define ITEMS_H
13
14#ifndef CB_H
15#include <cb.h>
16#endif
17#ifndef ARBDB_BASE_H
18#include <arbdb_base.h>
19#endif
20#ifndef ARB_ASSERT_H
21#include <arb_assert.h>
22#endif
23
24
25#define it_assert(cond) arb_assert(cond)
26
27enum QUERY_ITEM_TYPE {
28    QUERY_ITEM_SPECIES,
29    QUERY_ITEM_GENES,
30    QUERY_ITEM_EXPERIMENTS,
31
32    QUERY_ITEM_TYPES // how many different types do we have
33};
34
35enum QUERY_RANGE {
36    QUERY_CURRENT_ITEM,
37    QUERY_MARKED_ITEMS,
38    QUERY_ALL_ITEMS
39};
40
41struct                            MutableItemSelector;
42typedef const MutableItemSelector ItemSelector;
43
44struct MutableItemSelector { // @@@ remove AW_root arguments!
45    QUERY_ITEM_TYPE type;
46
47    // if user selects an item in the result list,
48    // this callback sets the appropriate AWARs
49    // - for species: AWAR_SPECIES_NAME is changed (item_name = 'species_name')
50    // - for genes: AWAR_GENE_NAME and AWAR_SPECIES_NAME are changed (item_name = 'species_name/gene_name')
51
52    void (*update_item_awars)(GBDATA* gb_main, AW_root *aw_root, const char *item_name);
53    char *(*generate_item_id)(GBDATA *gb_main, GBDATA *gb_item); // @@@ remove parameter 'gb_main'
54    GBDATA *(*find_item_by_id)(GBDATA *gb_main, const char *id);
55    void (*selection_list_rescan_cb)(AW_window*, GBDATA *gb_main, long bitfilter);
56
57    int item_name_length; // -1 means "unknown" (might be long)
58
59    const char *change_key_path;
60    const char *item_name;                          // "species" or "gene" or "experiment" or "organism"
61    const char *items_name;                         // "species" or "genes" or "experiments" or "organisms"
62    const char *id_field;                           // e.g. "name" for species, genes
63
64    GBDATA *(*get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE); // AW_root may be NULL for QUERY_ALL_ITEMS and QUERY_MARKED_ITEMS
65    GBDATA *(*get_next_item_container)(GBDATA *, QUERY_RANGE);             // use same QUERY_RANGE as in get_first_item_container()
66
67    GBDATA *(*get_first_item)(GBDATA *, QUERY_RANGE);
68    GBDATA *(*get_next_item)(GBDATA *, QUERY_RANGE);
69
70    GBDATA *(*get_selected_item)(GBDATA *gb_main, AW_root *aw_root); // searches the currently selected item
71    void (*add_selection_changed_cb)(AW_root *aw_root, const RootCallback& cb); // gets called when selected item changes
72
73    ItemSelector *parent_selector;              // selector of parent item (or NULL if item has no parents)
74    GBDATA *(*get_parent)(GBDATA *gb_item);     // if 'parent_selector' is defined, this function returns the parent of the item
75};
76
77#define AWAR_KEY_SELECT "tmp/viewkeys/key_select"
78
79struct FieldSelectionParam {
80    GBDATA     *gb_main;
81    const char *awar_name;
82    bool        fallback2default;
83
84    FieldSelectionParam(GBDATA *gb_main_, const char *awar_name_, bool fallback2default_)
85        : gb_main(gb_main_),
86          awar_name(awar_name_),
87          fallback2default(fallback2default_)
88    {}
89};
90
91void popup_select_species_field_window(AW_window *aww, FieldSelectionParam *fsp);
92
93struct MutableBoundItemSel {
94    GBDATA        *gb_main;
95    ItemSelector&  selector;
96
97    MutableBoundItemSel(GBDATA *gb_main_, ItemSelector& selector_)
98        : gb_main(gb_main_),
99          selector(selector_)
100    {
101        it_assert(gb_main);
102        it_assert(&selector);
103    }
104};
105
106typedef const MutableBoundItemSel BoundItemSel;
107
108ItemSelector& SPECIES_get_selector();
109ItemSelector& ORGANISM_get_selector();
110
111#else
112#error items.h included twice
113#endif // ITEMS_H
Note: See TracBrowser for help on using the repository browser.