ARB
items.h
Go to the documentation of this file.
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 
33 
34  QUERY_ITEM_TYPES // how many different types do we have
35 };
36 
38  return type == QUERY_ITEM_SPECIES || type == QUERY_ITEM_ORGANISM;
39 }
40 
45 };
46 
48 typedef const MutableItemSelector ItemSelector;
49 
50 struct MutableItemSelector { // @@@ remove AW_root arguments!
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')
57 
58  void (*update_item_awars)(GBDATA* gb_main, AW_root *aw_root, const char *item_name);
59  char *(*generate_item_id)(GBDATA *gb_main, GBDATA *gb_item); // @@@ remove parameter 'gb_main'
60  GBDATA *(*find_item_by_id)(GBDATA *gb_main, const char *id);
62 
63  int item_name_length; // -1 means "unknown" (might be long)
64 
65  const char *change_key_path;
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
69 
70  GBDATA *(*get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE); // AW_root may be NULp for QUERY_ALL_ITEMS and QUERY_MARKED_ITEMS
71  GBDATA *(*get_next_item_container)(GBDATA *, QUERY_RANGE); // use same QUERY_RANGE as in get_first_item_container()
72 
73  GBDATA *(*get_first_item)(GBDATA *, QUERY_RANGE);
74  GBDATA *(*get_next_item)(GBDATA *, QUERY_RANGE);
75 
76  GBDATA *(*get_selected_item)(GBDATA *gb_main, AW_root *aw_root); // searches the currently selected item
77  void (*add_selection_changed_cb)(AW_root *aw_root, const RootCallback& cb); // gets called when selected item changes
78 
79  ItemSelector *parent_selector; // selector of parent item (or NULp if item has no parents)
80  GBDATA *(*get_parent)(GBDATA *gb_item); // if 'parent_selector' is defined, this function returns the parent of the item
81 
82  void (*trigger_display_refresh)(); // shall be called when displays shall be refreshed (e.g. tree-display for species)
83 };
84 
88 
89  MutableBoundItemSel(GBDATA *gb_main_, ItemSelector& selector_)
90  : gb_main(gb_main_),
91  selector(selector_)
92  {
93  it_assert(gb_main);
94  it_assert(&selector);
95  }
96 
97  GBDATA *get_any_item() const;
98 
99  GBDATA *get_first_item_container(AW_root *awr, QUERY_RANGE range) const { return selector.get_first_item_container(gb_main, awr, range); }
100  GBDATA *get_next_item_container(GBDATA *gb_cont, QUERY_RANGE range) const { return selector.get_next_item_container(gb_cont, range); }
101 
102  GBDATA *get_first_item(GBDATA *gb_cont, QUERY_RANGE range) const { return selector.get_first_item(gb_cont, range); }
103  GBDATA *get_next_item(GBDATA *gb_item, QUERY_RANGE range) const { return selector.get_next_item(gb_item, range); }
104 };
105 
107 
108 void 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);
109 
112 ItemSelector& SAI_get_selector(); // has reduced functionality (no change_keys defined)
113 
114 #else
115 #error items.h included twice
116 #endif // ITEMS_H
const char * item_name
Definition: items.h:66
GB_TYPES type
const char * id
Definition: AliAdmin.cxx:17
ItemSelector * parent_selector
Definition: items.h:79
GBDATA * get_any_item() const
Definition: items.cxx:14
ItemSelector & ORGANISM_get_selector()
Definition: species.cxx:140
void(* add_selection_changed_cb)(AW_root *aw_root, const RootCallback &cb)
Definition: items.h:77
const MutableItemSelector ItemSelector
Definition: items.h:47
GBDATA * get_first_item(GBDATA *gb_cont, QUERY_RANGE range) const
Definition: items.h:102
#define cb(action)
bool speciesOrOrganism(QUERY_ITEM_TYPE type)
Definition: items.h:37
const char * plural(NUM val)
Definition: arb_string.h:108
const char * change_key_path
Definition: items.h:65
void(* selection_list_rescan_cb)(AW_window *, GBDATA *gb_main)
Definition: items.h:61
void 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)
Definition: itemtools.cxx:33
ItemSelector & selector
Definition: items.h:87
GBDATA * get_next_item(GBDATA *gb_item, QUERY_RANGE range) const
Definition: items.h:103
GBDATA *(* get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE)
Definition: items.h:70
GBDATA *(* get_next_item_container)(GBDATA *, QUERY_RANGE)
Definition: items.h:71
void(* trigger_display_refresh)()
Definition: items.h:82
ItemSelector & SAI_get_selector()
Definition: SAIs.cxx:92
const char * items_name
Definition: items.h:67
GBDATA * get_next_item_container(GBDATA *gb_cont, QUERY_RANGE range) const
Definition: items.h:100
int item_name_length
Definition: items.h:63
#define it_assert(cond)
Definition: items.h:25
GBDATA *(* get_first_item)(GBDATA *, QUERY_RANGE)
Definition: items.h:73
QUERY_RANGE
Definition: items.h:41
QUERY_ITEM_TYPE
Definition: items.h:27
GBDATA *(* get_next_item)(GBDATA *, QUERY_RANGE)
Definition: items.h:74
void(* update_item_awars)(GBDATA *gb_main, AW_root *aw_root, const char *item_name)
Definition: items.h:58
GBDATA * get_first_item_container(AW_root *awr, QUERY_RANGE range) const
Definition: items.h:99
MutableBoundItemSel(GBDATA *gb_main_, ItemSelector &selector_)
Definition: items.h:89
ItemSelector & SPECIES_get_selector()
Definition: species.cxx:139
GBDATA * gb_main
Definition: items.h:86
GBDATA * gb_main
Definition: adname.cxx:32
const MutableBoundItemSel BoundItemSel
Definition: items.h:106
const char * id_field
Definition: items.h:68
QUERY_ITEM_TYPE type
Definition: items.h:51