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_SAI:
25  case QUERY_ITEM_SPECIES:
27  case QUERY_ITEM_TYPES: it_assert(0); break;
28  }
29  it_assert(item_type_id);
30  return GBS_global_string("%s_%s", window_id, item_type_id);
31 }
32 
33 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) {
34  const char *s_id = itemTypeSpecificWindowID(itemType, id);
35  char *s_title = GBS_global_string_copy(title_format, plural ? itemType.items_name : itemType.item_name);
36 
37  aws->init(aw_root, s_id, s_title);
38  free(s_title);
39 }
40 
const char * item_name
Definition: items.h:66
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
const char * itemTypeSpecificWindowID(const ItemSelector &selector, const char *window_id)
Definition: itemtools.cxx:15
bool speciesOrOrganism(QUERY_ITEM_TYPE type)
Definition: items.h:37
const char * plural(NUM val)
Definition: arb_string.h:108
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:33
const char * items_name
Definition: items.h:67
#define it_assert(cond)
Definition: items.h:25
#define NULp
Definition: cxxforward.h:116
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:194
QUERY_ITEM_TYPE type
Definition: items.h:51