ARB
itemtools.cxx
Go to the documentation of this file.
1 // ============================================================ //
2 // //
3 // File : itemtools.cxx //
4 // Purpose : item-specific toolkit //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in July 2015 //
7 // http://www.arb-home.de/ //
8 // //
9 // ============================================================ //
10 
11 #include "items.h"
12 #include <arb_msg.h>
13 #include <aw_window.hxx>
14 
15 inline const char *itemTypeSpecificWindowID(const ItemSelector& selector, const char *window_id) {
16  if (speciesOrOrganism(selector.type)) {
17  return window_id; // for species return given window id
18  }
19  const char *item_type_id = NULp;
20  switch (selector.type) {
21  case QUERY_ITEM_GENES: item_type_id = "GENE"; break;
22  case QUERY_ITEM_EXPERIMENTS: item_type_id = "EXPERIMENT"; break;
23 
24  case QUERY_ITEM_SPECIES:
26  case QUERY_ITEM_TYPES: it_assert(0); break;
27  }
28  it_assert(item_type_id);
29  return GBS_global_string("%s_%s", window_id, item_type_id);
30 }
31 
32 void init_itemType_specific_window(AW_root *aw_root, AW_window_simple *aws, const ItemSelector& itemType, const char *id, const char *title_format, bool plural) {
33  const char *s_id = itemTypeSpecificWindowID(itemType, id);
34  char *s_title = GBS_global_string_copy(title_format, plural ? itemType.items_name : itemType.item_name);
35 
36  aws->init(aw_root, s_id, s_title);
37  free(s_title);
38 }
39 
const char * item_name
Definition: items.h:65
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
const char * itemTypeSpecificWindowID(const ItemSelector &selector, const char *window_id)
Definition: itemtools.cxx:15
bool speciesOrOrganism(QUERY_ITEM_TYPE type)
Definition: items.h:36
void init_itemType_specific_window(AW_root *aw_root, AW_window_simple *aws, const ItemSelector &itemType, const char *id, const char *title_format, bool plural)
Definition: itemtools.cxx:32
const char * items_name
Definition: items.h:66
#define it_assert(cond)
Definition: items.h:25
const char * plural(int val)
#define NULp
Definition: cxxforward.h:97
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:195
QUERY_ITEM_TYPE type
Definition: items.h:50