ARB
species.cxx
Go to the documentation of this file.
1 // ================================================================ //
2 // //
3 // File : species.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // ================================================================ //
10 
11 #include "item_sel_list.h"
12 
13 #include <arbdbt.h>
14 #include <aw_root.hxx>
15 #include <aw_awars.hxx>
16 
17 
19  return GBT_get_species_data(gb_main);
20 }
22  return NULp; // there is only ONE species_data
23 }
24 
25 static void select_species(GBDATA*, AW_root *aw_root, const char *item_name) {
26  aw_root->awar(AWAR_SPECIES_NAME)->write_string(item_name);
27 }
28 static void select_organism(GBDATA*, AW_root *aw_root, const char *item_name) {
29  aw_root->awar(AWAR_ORGANISM_NAME)->write_string(item_name);
30 }
31 
33  const char *species_name = aw_root->awar(AWAR_SPECIES_NAME)->read_char_pntr();
34  return species_name[0] ? GBT_find_species(gb_main, species_name) : NULp;
35 }
37  const char *organism_name = aw_root->awar(AWAR_ORGANISM_NAME)->read_char_pntr();
38  return organism_name[0] ? GEN_find_organism(gb_main, organism_name) : NULp;
39 }
40 
41 static void add_selected_species_changed_cb(AW_root *aw_root, const RootCallback& cb) {
42  aw_root->awar(AWAR_SPECIES_NAME)->add_callback(cb);
43 }
44 
45 static char* get_species_id(GBDATA *, GBDATA *gb_species) {
46  GBDATA *gb_name = GB_entry(gb_species, "name");
47  if (!gb_name) return NULp; // species w/o name -> skip
48  return GB_read_as_string(gb_name);
49 }
50 
51 static GBDATA *find_species_by_id(GBDATA *gb_main, const char *id) {
52  return GBT_find_species(gb_main, id); // id is 'name' field
53 }
54 
56  GBDATA *gb_first = NULp;
57  switch (range) {
58  case QUERY_ALL_ITEMS: gb_first = GBT_first_species_rel_species_data(gb_species_data); break;
59  case QUERY_MARKED_ITEMS: gb_first = GBT_first_marked_species_rel_species_data(gb_species_data); break;
60  case QUERY_CURRENT_ITEM: gb_first = get_selected_species(GB_get_root(gb_species_data), AW_root::SINGLETON); break;
61  }
62  return gb_first;
63 }
64 static GBDATA *get_next_species(GBDATA *gb_prev, QUERY_RANGE range) {
65  GBDATA *gb_next = NULp;
66  switch (range) {
67  case QUERY_ALL_ITEMS: gb_next = GBT_next_species(gb_prev); break;
68  case QUERY_MARKED_ITEMS: gb_next = GBT_next_marked_species(gb_prev); break;
69  case QUERY_CURRENT_ITEM: gb_next = NULp; break;
70  }
71  return gb_next;
72 }
74  GBDATA *gb_first = NULp;
75  GBDATA *gb_main = GB_get_root(gb_species_data);
76  switch (range) {
77  case QUERY_ALL_ITEMS: gb_first = GEN_first_organism(gb_main); break;
78  case QUERY_MARKED_ITEMS: gb_first = GEN_first_marked_organism(gb_main); break;
79  case QUERY_CURRENT_ITEM: gb_first = get_selected_organism(gb_main, AW_root::SINGLETON); break;
80  }
81  return gb_first;
82 }
83 static GBDATA *get_next_organism(GBDATA *gb_prev, QUERY_RANGE range) {
84  GBDATA *gb_next = NULp;
85  switch (range) {
86  case QUERY_ALL_ITEMS: gb_next = GEN_next_organism(gb_prev); break;
87  case QUERY_MARKED_ITEMS: gb_next = GEN_next_marked_organism(gb_prev); break;
88  case QUERY_CURRENT_ITEM: gb_next = NULp; break;
89  }
90  return gb_next;
91 }
92 
95 }
96 
103  12,
105  "species",
106  "species",
107  "name",
114  NULp, NULp,
116 };
117 
124  12,
126  "organism",
127  "organisms",
128  "name",
135  NULp, NULp,
137 };
138 
141 
static void refresh_displayed_species()
Definition: species.cxx:93
GBDATA * GBT_first_marked_species_rel_species_data(GBDATA *gb_species_data)
Definition: aditem.cxx:109
#define AWAR_ORGANISM_NAME
static GBDATA * get_next_species(GBDATA *gb_prev, QUERY_RANGE range)
Definition: species.cxx:64
char * GB_read_as_string(GBDATA *gbd)
Definition: arbdb.cxx:1054
static GBDATA * find_species_by_id(GBDATA *gb_main, const char *id)
Definition: species.cxx:51
static GBDATA * get_first_species_data(GBDATA *gb_main, AW_root *, QUERY_RANGE)
Definition: species.cxx:18
GBDATA * GEN_find_organism(GBDATA *gb_main, const char *name)
Definition: adGene.cxx:738
#define cb(action)
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:234
static GBDATA * get_selected_organism(GBDATA *gb_main, AW_root *aw_root)
Definition: species.cxx:36
GBDATA * GBT_first_species_rel_species_data(GBDATA *gb_species_data)
Definition: aditem.cxx:121
static GBDATA * get_next_species_data(GBDATA *, QUERY_RANGE)
Definition: species.cxx:21
const char * read_char_pntr() const
Definition: AW_awar.cxx:171
static AW_root * SINGLETON
Definition: aw_root.hxx:102
GBDATA * gb_species_data
Definition: adname.cxx:34
void touch()
Definition: AW_awar.cxx:210
GBDATA * GEN_next_marked_organism(GBDATA *gb_organism)
Definition: adGene.cxx:783
GBDATA * GB_get_root(GBDATA *gbd)
Definition: arbdb.cxx:1738
#define AWAR_TREE_REFRESH
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
ItemSelector & SPECIES_get_selector()
Definition: species.cxx:139
#define AWAR_SPECIES_NAME
GBDATA * GEN_next_organism(GBDATA *gb_organism)
Definition: adGene.cxx:755
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
static GBDATA * get_first_species(GBDATA *gb_species_data, QUERY_RANGE range)
Definition: species.cxx:55
void species_field_selection_list_update_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:189
static char * get_species_id(GBDATA *, GBDATA *gb_species)
Definition: species.cxx:45
static struct MutableItemSelector ITEM_species
Definition: species.cxx:97
static struct MutableItemSelector ITEM_organism
Definition: species.cxx:118
QUERY_RANGE
Definition: items.h:40
ItemSelector & ORGANISM_get_selector()
Definition: species.cxx:140
static GBDATA * get_selected_species(GBDATA *gb_main, AW_root *aw_root)
Definition: species.cxx:32
static void add_selected_species_changed_cb(AW_root *aw_root, const RootCallback &cb)
Definition: species.cxx:41
static void select_species(GBDATA *, AW_root *aw_root, const char *item_name)
Definition: species.cxx:25
#define CHANGE_KEY_PATH
Definition: arbdbt.h:86
static GBDATA * get_first_organism(GBDATA *gb_species_data, QUERY_RANGE range)
Definition: species.cxx:73
static void select_organism(GBDATA *, AW_root *aw_root, const char *item_name)
Definition: species.cxx:28
static GBDATA * get_next_organism(GBDATA *gb_prev, QUERY_RANGE range)
Definition: species.cxx:83
GBDATA * GBT_next_species(GBDATA *gb_species)
Definition: aditem.cxx:128
#define NULp
Definition: cxxforward.h:97
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
Definition: aditem.cxx:139
GB_ERROR write_string(const char *aw_string)
GBDATA * gb_main
Definition: adname.cxx:33
GBDATA * GEN_first_marked_organism(GBDATA *gb_main)
Definition: adGene.cxx:777
GBDATA * GEN_first_organism(GBDATA *gb_main)
Definition: adGene.cxx:749
GBDATA * GB_entry(GBDATA *father, const char *key)
Definition: adquery.cxx:334
GBDATA * GBT_get_species_data(GBDATA *gb_main)
Definition: aditem.cxx:105