ARB
item_sel_list.h
Go to the documentation of this file.
1 // ==================================================================== //
2 // //
3 // File : item_sel_list.h //
4 // Purpose : selection lists for items (ItemSelector) //
5 // //
6 // //
7 // Coded by Ralf Westram (coder@reallysoft.de) in May 2005 //
8 // Copyright Department of Microbiology (Technical University Munich) //
9 // //
10 // Visit our web site at: http://www.arb-home.de/ //
11 // //
12 // ==================================================================== //
13 
14 #ifndef ITEM_SEL_LIST_H
15 #define ITEM_SEL_LIST_H
16 
17 #ifndef AW_SELECT_HXX
18 #include <aw_select.hxx>
19 #endif
20 #ifndef ITEMS_H
21 #include "items.h"
22 #endif
23 #ifndef _GLIBCXX_STRING
24 #include <string>
25 #endif
26 
27 #define PSEUDO_FIELD_ANY_FIELD "[any field]"
28 #define PSEUDO_FIELD_ALL_FIELDS "[all fields]"
29 #define PSEUDO_FIELD_ANY_FIELD_REC "[any recursive]"
30 #define PSEUDO_FIELD_ALL_FIELDS_REC "[all recursive]"
31 
33  SF_STANDARD = 0, // normal fields
34  SF_PSEUDO = 1, // pseudo-fields (see defines above)
35  SF_HIDDEN = 2, // fields hidden by user
36  SF_ALLOW_NEW = 4, // allow on-the-fly creation of new fields
37  SF_SHOW_TYPE = 8, // show fieldtype prefix
38 };
39 
40 
46 
47 CONSTEXPR long FIELD_FILTER_STRING_READABLE = (1<<GB_BYTE)|(1<<GB_INT)|(1<<GB_FLOAT)|(1<<GB_STRING)|(1<<GB_BITS); // as supported by GB_read_as_string()
48 
49 CONSTEXPR long FIELD_UNFILTERED = -1L; // any field or container
50 CONSTEXPR long FIELD_FILTER_ANY_FIELD = (FIELD_UNFILTERED ^ (1<<GB_DB)); // no containers
51 
53 
54 
55 class Itemfield_Selection : public AW_DB_selection { // derived from a Noncopyable
56  long type_filter;
57  SelectableFields field_filter;
58  ItemSelector& selector;
59 
60  bool shall_display_type(GB_TYPES key_type) const { return type_filter & (1 << key_type); }
61 
62 public:
64  GBDATA *gb_key_data,
65  long type_filter_,
66  SelectableFields field_filter_,
67  ItemSelector& selector_);
68 
69  void fill() OVERRIDE;
70 
71  ItemSelector& get_selector() const { return selector; }
72  long get_type_filter() const { return type_filter; }
73 };
74 
75 class FieldSelDef {
76  std::string awar_name;
77  std::string purpose;
78  RefPtr<GBDATA> gb_main;
79  RefPtr<ItemSelector> selector; // @@@ gb_main + selector = BoundItemSel (replace?)
80  long type_filter;
81  SelectableFields field_filter;
82 
83 public:
84  FieldSelDef(const char *awar_name_, GBDATA *gb_main_, ItemSelector& selector_, long type_filter_, const char *purpose_ = "field", SelectableFields field_filter_ = SF_STANDARD)
93  : awar_name(awar_name_),
94  purpose(purpose_),
95  gb_main(gb_main_),
96  selector(&selector_),
97  type_filter(type_filter_),
98  field_filter(field_filter_)
99  {}
100 
101  const std::string& get_awarname() const { return awar_name; }
102  const std::string& get_described_field() const { return purpose; }
103  long get_type_filter() const { return type_filter; }
104  SelectableFields get_field_filter() const { return field_filter; }
105  GBDATA *get_gb_main() const { return gb_main; }
106  ItemSelector& get_itemtype() const { return *selector; }
107 
108  // for internal use only:
109  bool new_fields_allowed() const { return field_filter & SF_ALLOW_NEW; }
110  Itemfield_Selection *build_sel(AW_selection_list *from_sellist) const;
111  bool matches4reuse(const FieldSelDef& other) const;
112 };
113 
115  FIF_NAME_SELECTED = 1, // fail if 'name' field selected
116  FIF_NO_FIELD_SELECTED = 2, // fail if NO_FIELD_SELECTED
117 
118  // use-cases:
122 };
123 
124 Itemfield_Selection *create_itemfield_selection_list( AW_window *aws, const FieldSelDef& selDef, const char *at);
125 void create_itemfield_selection_button(AW_window *aws, const FieldSelDef& selDef, const char *at);
126 const char *prepare_and_get_selected_itemfield(AW_root *awr, const char *awar_name, GBDATA *gb_main, const ItemSelector& itemtype, FailIfField failIf = FIF_STANDARD);
127 const char *get_itemfield_type_awarname(const char *itemfield_awarname);
128 
130  RESCAN_REFRESH = 1, // scan database for unregistered/unused fields and update the field list
131  RESCAN_SHOW_ALL = 2, // unhide all hidden fields
132 };
133 
134 // @@@ generalize (use BoundItemSel)
135 
138 
141 
144 
147 
148 #else
149 #error item_sel_list.h included twice
150 #endif // ITEM_SEL_LIST_H
151 
const std::string & get_described_field() const
Itemfield_Selection * build_sel(AW_selection_list *from_sellist) const
CONSTEXPR long FIELD_FILTER_FLOAT_WRITEABLE
Definition: item_sel_list.h:45
Definition: arbdb.h:65
return string(buffer, length)
Definition: arbdb.h:69
bool new_fields_allowed() const
void create_itemfield_selection_button(AW_window *aws, const FieldSelDef &selDef, const char *at)
long get_type_filter() const
Definition: item_sel_list.h:72
Itemfield_Selection * create_itemfield_selection_list(AW_window *aws, const FieldSelDef &selDef, const char *at)
GBDATA * get_gb_main() const
void fill() OVERRIDE
void gene_field_selection_list_unhide_all_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:191
void species_field_selection_list_update_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:189
const std::string & get_awarname() const
ItemSelector & get_itemtype() const
SelectableFields
Definition: item_sel_list.h:32
CONSTEXPR long FIELD_FILTER_NDS
Definition: item_sel_list.h:52
const char * get_itemfield_type_awarname(const char *itemfield_awarname)
FieldSelDef(const char *awar_name_, GBDATA *gb_main_, ItemSelector &selector_, long type_filter_, const char *purpose_="field", SelectableFields field_filter_=SF_STANDARD)
Definition: item_sel_list.h:84
void experiment_field_selection_list_update_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:195
const char * prepare_and_get_selected_itemfield(AW_root *awr, const char *awar_name, GBDATA *gb_main, const ItemSelector &itemtype, FailIfField failIf=FIF_STANDARD)
void experiment_field_selection_list_unhide_all_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:194
Definition: arbdb.h:67
Definition: arbdb.h:78
void species_field_selection_list_rescan(GBDATA *gb_main, RescanMode mode)
Definition: changekey.cxx:97
Itemfield_Selection(AW_selection_list *sellist_, GBDATA *gb_key_data, long type_filter_, SelectableFields field_filter_, ItemSelector &selector_)
FailIfField
CONSTEXPR long FIELD_FILTER_STRING_WRITEABLE
Definition: item_sel_list.h:42
CONSTEXPR long FIELD_FILTER_ANY_FIELD
Definition: item_sel_list.h:50
SelectableFields get_field_filter() const
void species_field_selection_list_unhide_all_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:188
void gene_field_selection_list_rescan(GBDATA *gb_main, RescanMode mode)
Definition: changekey.cxx:129
bool matches4reuse(const FieldSelDef &other) const
#define OVERRIDE
Definition: cxxforward.h:112
RescanMode
void gene_field_selection_list_update_cb(AW_window *, GBDATA *gb_main)
Definition: changekey.cxx:192
ItemSelector & get_selector() const
Definition: item_sel_list.h:71
long get_type_filter() const
GB_TYPES
Definition: arbdb.h:62
CONSTEXPR long FIELD_FILTER_INT_WRITEABLE
Definition: item_sel_list.h:43
GBDATA * gb_main
Definition: adname.cxx:32
CONSTEXPR long FIELD_FILTER_STRING
Definition: item_sel_list.h:41
#define CONSTEXPR
Definition: cxxforward.h:108
CONSTEXPR long FIELD_FILTER_BYTE_WRITEABLE
Definition: item_sel_list.h:44
CONSTEXPR long FIELD_FILTER_STRING_READABLE
Definition: item_sel_list.h:47
CONSTEXPR long FIELD_UNFILTERED
Definition: item_sel_list.h:49
Definition: arbdb.h:66