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

Last change on this file was 18758, checked in by westram, 4 years ago
  • mark some todos for DbScanner + ItemSelector.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
RevLine 
[7710]1// ============================================================ //
2//                                                              //
3//   File      : items.h                                        //
4//   Purpose   :                                                //
5//                                                              //
6//   Institute of Microbiology (Technical University Munich)    //
7//   http://www.arb-home.de/                                    //
8//                                                              //
9// ============================================================ //
[2]10
[7710]11#ifndef ITEMS_H
12#define ITEMS_H
[5968]13
[10209]14#ifndef CB_H
15#include <cb.h>
[2]16#endif
[10209]17#ifndef ARBDB_BASE_H
18#include <arbdb_base.h>
19#endif
[7806]20#ifndef ARB_ASSERT_H
21#include <arb_assert.h>
22#endif
[2]23
[7806]24
[7710]25#define it_assert(cond) arb_assert(cond)
[6381]26
[7812]27enum QUERY_ITEM_TYPE {
[7804]28    QUERY_ITEM_SPECIES,
[18211]29    QUERY_ITEM_ORGANISM,
[7804]30    QUERY_ITEM_GENES,
31    QUERY_ITEM_EXPERIMENTS,
[18754]32    QUERY_ITEM_SAI,
[142]33
[7804]34    QUERY_ITEM_TYPES // how many different types do we have
[7812]35};
[142]36
[18211]37inline bool speciesOrOrganism(QUERY_ITEM_TYPE type) {
38    return type == QUERY_ITEM_SPECIES || type == QUERY_ITEM_ORGANISM;
39}
40
[7812]41enum QUERY_RANGE {
[7657]42    QUERY_CURRENT_ITEM,
43    QUERY_MARKED_ITEMS,
44    QUERY_ALL_ITEMS
[7812]45};
[142]46
[7806]47struct                            MutableItemSelector;
48typedef const MutableItemSelector ItemSelector;
49
50struct MutableItemSelector { // @@@ remove AW_root arguments!
[7804]51    QUERY_ITEM_TYPE type;
[142]52
53    // if user selects an item in the result list,
54    // this callback sets the appropriate AWARs
55    // - for species: AWAR_SPECIES_NAME is changed (item_name = 'species_name')
56    // - for genes: AWAR_GENE_NAME and AWAR_SPECIES_NAME are changed (item_name = 'species_name/gene_name')
[7804]57
[142]58    void (*update_item_awars)(GBDATA* gb_main, AW_root *aw_root, const char *item_name);
[7657]59    char *(*generate_item_id)(GBDATA *gb_main, GBDATA *gb_item); // @@@ remove parameter 'gb_main'
[3317]60    GBDATA *(*find_item_by_id)(GBDATA *gb_main, const char *id);
[14786]61    void (*selection_list_rescan_cb)(AW_window*, GBDATA *gb_main);
[142]62
[11265]63    int item_name_length; // -1 means "unknown" (might be long)
64
[142]65    const char *change_key_path;
[5865]66    const char *item_name;                          // "species" or "gene" or "experiment" or "organism"
67    const char *items_name;                         // "species" or "genes" or "experiments" or "organisms"
68    const char *id_field;                           // e.g. "name" for species, genes
[142]69
[16763]70    GBDATA *(*get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE); // AW_root may be NULp for QUERY_ALL_ITEMS and QUERY_MARKED_ITEMS
[7804]71    GBDATA *(*get_next_item_container)(GBDATA *, QUERY_RANGE);             // use same QUERY_RANGE as in get_first_item_container()
[6385]72
[7804]73    GBDATA *(*get_first_item)(GBDATA *, QUERY_RANGE);
74    GBDATA *(*get_next_item)(GBDATA *, QUERY_RANGE);
[449]75
[18758]76    // @@@ !Logic error: 'get_selected_item' and 'add_selection_changed_cb' normally hardcode some SAI name (these are e.g. wrong in Merge Tool, where e.g. 2 species ItemSelectors exists)
[449]77    GBDATA *(*get_selected_item)(GBDATA *gb_main, AW_root *aw_root); // searches the currently selected item
[10349]78    void (*add_selection_changed_cb)(AW_root *aw_root, const RootCallback& cb); // gets called when selected item changes
[3857]79
[16763]80    ItemSelector *parent_selector;              // selector of parent item (or NULp if item has no parents)
[7804]81    GBDATA *(*get_parent)(GBDATA *gb_item);     // if 'parent_selector' is defined, this function returns the parent of the item
[14096]82
83    void (*trigger_display_refresh)(); // shall be called when displays shall be refreshed (e.g. tree-display for species)
[142]84};
85
[7806]86struct MutableBoundItemSel {
87    GBDATA        *gb_main;
88    ItemSelector&  selector;
[142]89
[7806]90    MutableBoundItemSel(GBDATA *gb_main_, ItemSelector& selector_)
[7710]91        : gb_main(gb_main_),
92          selector(selector_)
93    {
94        it_assert(gb_main);
95        it_assert(&selector);
96    }
[15054]97
98    GBDATA *get_any_item() const;
99
100    GBDATA *get_first_item_container(AW_root *awr, QUERY_RANGE range) const { return selector.get_first_item_container(gb_main, awr, range); }
101    GBDATA *get_next_item_container(GBDATA *gb_cont, QUERY_RANGE range) const { return selector.get_next_item_container(gb_cont, range); }
102
103    GBDATA *get_first_item(GBDATA *gb_cont, QUERY_RANGE range) const { return selector.get_first_item(gb_cont, range); }
104    GBDATA *get_next_item(GBDATA *gb_item, QUERY_RANGE range) const { return selector.get_next_item(gb_item, range); }
[2]105};
106
[7806]107typedef const MutableBoundItemSel BoundItemSel;
108
[14065]109void 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);
110
[7806]111ItemSelector& SPECIES_get_selector();
112ItemSelector& ORGANISM_get_selector();
[18754]113ItemSelector& SAI_get_selector(); // has reduced functionality (no change_keys defined)
[7806]114
[5968]115#else
[7710]116#error items.h included twice
117#endif // ITEMS_H
Note: See TracBrowser for help on using the repository browser.