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 
32 
33  QUERY_ITEM_TYPES // how many different types do we have
34 };
35 
37  return type == QUERY_ITEM_SPECIES || type == QUERY_ITEM_ORGANISM;
38 }
39 
44 };
45 
47 typedef const MutableItemSelector ItemSelector;
48 
49 struct MutableItemSelector { // @@@ remove AW_root arguments!
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);
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 
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 
106 
107 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);
108 
111 
112 #else
113 #error items.h included twice
114 #endif // ITEMS_H
const char * item_name
Definition: items.h:65
GB_TYPES type
const char * id
Definition: AliAdmin.cxx:17
ItemSelector * parent_selector
Definition: items.h:78
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:76
const MutableItemSelector ItemSelector
Definition: items.h:46
GBDATA * get_first_item(GBDATA *gb_cont, QUERY_RANGE range) const
Definition: items.h:101
#define cb(action)
bool speciesOrOrganism(QUERY_ITEM_TYPE type)
Definition: items.h:36
const char * change_key_path
Definition: items.h:64
void(* selection_list_rescan_cb)(AW_window *, GBDATA *gb_main)
Definition: items.h:60
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:32
ItemSelector & selector
Definition: items.h:86
GBDATA * get_next_item(GBDATA *gb_item, QUERY_RANGE range) const
Definition: items.h:102
GBDATA *(* get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE)
Definition: items.h:69
GBDATA *(* get_next_item_container)(GBDATA *, QUERY_RANGE)
Definition: items.h:70
void(* trigger_display_refresh)()
Definition: items.h:81
const char * items_name
Definition: items.h:66
GBDATA * get_next_item_container(GBDATA *gb_cont, QUERY_RANGE range) const
Definition: items.h:99
int item_name_length
Definition: items.h:62
#define it_assert(cond)
Definition: items.h:25
GBDATA *(* get_first_item)(GBDATA *, QUERY_RANGE)
Definition: items.h:72
QUERY_RANGE
Definition: items.h:40
QUERY_ITEM_TYPE
Definition: items.h:27
GBDATA *(* get_next_item)(GBDATA *, QUERY_RANGE)
Definition: items.h:73
void(* update_item_awars)(GBDATA *gb_main, AW_root *aw_root, const char *item_name)
Definition: items.h:57
const char * plural(int val)
GBDATA * get_first_item_container(AW_root *awr, QUERY_RANGE range) const
Definition: items.h:98
MutableBoundItemSel(GBDATA *gb_main_, ItemSelector &selector_)
Definition: items.h:88
ItemSelector & SPECIES_get_selector()
Definition: species.cxx:139
GBDATA * gb_main
Definition: items.h:85
GBDATA * gb_main
Definition: adname.cxx:33
const MutableBoundItemSel BoundItemSel
Definition: items.h:105
const char * id_field
Definition: items.h:67
QUERY_ITEM_TYPE type
Definition: items.h:50