| 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 AW_BASE_HXX |
|---|
| 15 | #include <aw_base.hxx> |
|---|
| 16 | #endif |
|---|
| 17 | #ifndef ARB_ASSERT_H |
|---|
| 18 | #include <arb_assert.h> |
|---|
| 19 | #endif |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | #define it_assert(cond) arb_assert(cond) |
|---|
| 23 | |
|---|
| 24 | enum QUERY_ITEM_TYPE { |
|---|
| 25 | QUERY_ITEM_SPECIES, |
|---|
| 26 | QUERY_ITEM_GENES, |
|---|
| 27 | QUERY_ITEM_EXPERIMENTS, |
|---|
| 28 | |
|---|
| 29 | QUERY_ITEM_TYPES // how many different types do we have |
|---|
| 30 | }; |
|---|
| 31 | |
|---|
| 32 | enum QUERY_RANGE { |
|---|
| 33 | QUERY_CURRENT_ITEM, |
|---|
| 34 | QUERY_MARKED_ITEMS, |
|---|
| 35 | QUERY_ALL_ITEMS |
|---|
| 36 | }; |
|---|
| 37 | |
|---|
| 38 | struct MutableItemSelector; |
|---|
| 39 | typedef const MutableItemSelector ItemSelector; |
|---|
| 40 | |
|---|
| 41 | struct MutableItemSelector { // @@@ remove AW_root arguments! |
|---|
| 42 | QUERY_ITEM_TYPE type; |
|---|
| 43 | |
|---|
| 44 | // if user selects an item in the result list, |
|---|
| 45 | // this callback sets the appropriate AWARs |
|---|
| 46 | // - for species: AWAR_SPECIES_NAME is changed (item_name = 'species_name') |
|---|
| 47 | // - for genes: AWAR_GENE_NAME and AWAR_SPECIES_NAME are changed (item_name = 'species_name/gene_name') |
|---|
| 48 | |
|---|
| 49 | void (*update_item_awars)(GBDATA* gb_main, AW_root *aw_root, const char *item_name); |
|---|
| 50 | char *(*generate_item_id)(GBDATA *gb_main, GBDATA *gb_item); // @@@ remove parameter 'gb_main' |
|---|
| 51 | GBDATA *(*find_item_by_id)(GBDATA *gb_main, const char *id); |
|---|
| 52 | AW_CB selection_list_rescan_cb; |
|---|
| 53 | int item_name_length; // -1 means "unknown" (might be long) |
|---|
| 54 | |
|---|
| 55 | const char *change_key_path; |
|---|
| 56 | const char *item_name; // "species" or "gene" or "experiment" or "organism" |
|---|
| 57 | const char *items_name; // "species" or "genes" or "experiments" or "organisms" |
|---|
| 58 | const char *id_field; // e.g. "name" for species, genes |
|---|
| 59 | |
|---|
| 60 | GBDATA *(*get_first_item_container)(GBDATA *, AW_root *, QUERY_RANGE); // AW_root may be NULL for QUERY_ALL_ITEMS and QUERY_MARKED_ITEMS |
|---|
| 61 | GBDATA *(*get_next_item_container)(GBDATA *, QUERY_RANGE); // use same QUERY_RANGE as in get_first_item_container() |
|---|
| 62 | |
|---|
| 63 | GBDATA *(*get_first_item)(GBDATA *, QUERY_RANGE); |
|---|
| 64 | GBDATA *(*get_next_item)(GBDATA *, QUERY_RANGE); |
|---|
| 65 | |
|---|
| 66 | GBDATA *(*get_selected_item)(GBDATA *gb_main, AW_root *aw_root); // searches the currently selected item |
|---|
| 67 | |
|---|
| 68 | ItemSelector *parent_selector; // selector of parent item (or NULL if item has no parents) |
|---|
| 69 | GBDATA *(*get_parent)(GBDATA *gb_item); // if 'parent_selector' is defined, this function returns the parent of the item |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | void popup_select_species_field_window(AW_window *aww, AW_CL cl_awar_name, AW_CL cl_gb_main); |
|---|
| 73 | |
|---|
| 74 | struct MutableBoundItemSel { |
|---|
| 75 | GBDATA *gb_main; |
|---|
| 76 | ItemSelector& selector; |
|---|
| 77 | |
|---|
| 78 | MutableBoundItemSel(GBDATA *gb_main_, ItemSelector& selector_) |
|---|
| 79 | : gb_main(gb_main_), |
|---|
| 80 | selector(selector_) |
|---|
| 81 | { |
|---|
| 82 | it_assert(gb_main); |
|---|
| 83 | it_assert(&selector); |
|---|
| 84 | } |
|---|
| 85 | }; |
|---|
| 86 | |
|---|
| 87 | typedef const MutableBoundItemSel BoundItemSel; |
|---|
| 88 | |
|---|
| 89 | ItemSelector& SPECIES_get_selector(); |
|---|
| 90 | ItemSelector& ORGANISM_get_selector(); |
|---|
| 91 | |
|---|
| 92 | #else |
|---|
| 93 | #error items.h included twice |
|---|
| 94 | #endif // ITEMS_H |
|---|