source: branches/stable/SL/ITEMS/items.h

Last change on this file was 18211, checked in by westram, 4 years ago
  • add new QUERY_ITEM_TYPE for organisms: QUERY_ITEM_ORGANISM
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 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_ORGANISM,
30    QUERY_ITEM_GENES,
31    QUERY_ITEM_EXPERIMENTS,
32
33    QUERY_ITEM_TYPES // how many different types do we have
34};
35
36inline bool speciesOrOrganism(QUERY_ITEM_TYPE type) {
37    return type == QUERY_ITEM_SPECIES || type == QUERY_ITEM_ORGANISM;
38}
39
40enum QUERY_RANGE {
41    QUERY_CURRENT_ITEM,
42    QUERY_MARKED_ITEMS,
43    QUERY_ALL_ITEMS
44};
45
46struct                            MutableItemSelector;
47typedef const MutableItemSelector ItemSelector;
48
49struct MutableItemSelector { // @@@ remove AW_root arguments!
50    QUERY_ITEM_TYPE type;
51
52    // if user selects an item in the result list,
53    // this callback sets the appropriate AWARs
54    // - for species: AWAR_SPECIES_NAME is changed (item_name = 'species_name')
55    // - for genes: AWAR_GENE_NAME and AWAR_SPECIES_NAME are changed (item_name = 'species_name/gene_name')
56
57    void (*update_item_awars)(GBDATA* gb_main, AW_root *aw_root, const char *item_name);
58    char *(*generate_item_id)(GBDATA *gb_main, GBDATA *gb_item); // @@@ remove parameter 'gb_main'
59    GBDATA *(*find_item_by_id)(GBDATA *gb_main, const char *id);
60    void (*selection_list_rescan_cb)(AW_window*, GBDATA *gb_main);
61
62    int item_name_length; // -1 means "unknown" (might be long)
63
64    const char *change_key_path;
65    const char *item_name;                          // "species" or "gene" or "experiment" or "organism"
66    const char *items_name;                         // "species" or "genes" or "experiments" or "organisms"
67    const char *id_field;                           // e.g. "name" for species, genes
68
69    GBDATA *(*get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE); // AW_root may be NULp for QUERY_ALL_ITEMS and QUERY_MARKED_ITEMS
70    GBDATA *(*get_next_item_container)(GBDATA *, QUERY_RANGE);             // use same QUERY_RANGE as in get_first_item_container()
71
72    GBDATA *(*get_first_item)(GBDATA *, QUERY_RANGE);
73    GBDATA *(*get_next_item)(GBDATA *, QUERY_RANGE);
74
75    GBDATA *(*get_selected_item)(GBDATA *gb_main, AW_root *aw_root); // searches the currently selected item
76    void (*add_selection_changed_cb)(AW_root *aw_root, const RootCallback& cb); // gets called when selected item changes
77
78    ItemSelector *parent_selector;              // selector of parent item (or NULp if item has no parents)
79    GBDATA *(*get_parent)(GBDATA *gb_item);     // if 'parent_selector' is defined, this function returns the parent of the item
80
81    void (*trigger_display_refresh)(); // shall be called when displays shall be refreshed (e.g. tree-display for species)
82};
83
84struct MutableBoundItemSel {
85    GBDATA        *gb_main;
86    ItemSelector&  selector;
87
88    MutableBoundItemSel(GBDATA *gb_main_, ItemSelector& selector_)
89        : gb_main(gb_main_),
90          selector(selector_)
91    {
92        it_assert(gb_main);
93        it_assert(&selector);
94    }
95
96    GBDATA *get_any_item() const;
97
98    GBDATA *get_first_item_container(AW_root *awr, QUERY_RANGE range) const { return selector.get_first_item_container(gb_main, awr, range); }
99    GBDATA *get_next_item_container(GBDATA *gb_cont, QUERY_RANGE range) const { return selector.get_next_item_container(gb_cont, range); }
100
101    GBDATA *get_first_item(GBDATA *gb_cont, QUERY_RANGE range) const { return selector.get_first_item(gb_cont, range); }
102    GBDATA *get_next_item(GBDATA *gb_item, QUERY_RANGE range) const { return selector.get_next_item(gb_item, range); }
103};
104
105typedef const MutableBoundItemSel BoundItemSel;
106
107void init_itemType_specific_window(AW_root *aw_root, class AW_window_simple *aws, const ItemSelector& itemType, const char *id, const char *title_format, bool plural = false);
108
109ItemSelector& SPECIES_get_selector();
110ItemSelector& ORGANISM_get_selector();
111
112#else
113#error items.h included twice
114#endif // ITEMS_H
Note: See TracBrowser for help on using the repository browser.