source: branches/stable/SL/REFENTRIES/refentries.h

Last change on this file was 8607, checked in by westram, 7 years ago

merge from e4fix [8135] [8136] [8137] [8138] [8139] [8140] [8141] [8142] [8143] [8144] [8222]
(this revives the reverted patches [8129] [8130] [8131] [8132]; see [8133])

  • fixes
    • some free/delete mismatches
    • wrong definition of ORF objects (Level was no bit value)
    • amino consensus (failed for columns only containing 'C')
  • rename
    • AA_sequence_term → orf_term
    • ED4_sequence_terminal_basic → ED4_abstract_sequence_terminal
  • cleaned up hierarchy dumps
  • tweaked is_terminal()/to_terminal()
File size: 3.4 KB
Line 
1// ============================================================ //
2//                                                              //
3//   File      : refentries.h                                   //
4//   Purpose   : functions for fields containing references to  //
5//               other item (as names)                          //
6//                                                              //
7//   Coded by Ralf Westram (coder@reallysoft.de) in June 2011   //
8//   Institute of Microbiology (Technical University Munich)    //
9//   http://www.arb-home.de/                                    //
10//                                                              //
11// ============================================================ //
12
13#ifndef REFENTRIES_H
14#define REFENTRIES_H
15
16#ifndef ARB_ERROR_H
17#include <arb_error.h>
18#endif
19#ifndef ARBDB_BASE_H
20#include <arbdb_base.h>
21#endif
22#ifndef AW_BASE_HXX
23#include <aw_base.hxx>
24#endif
25#ifndef _GLIBCXX_SET
26#include <set>
27#endif
28#ifndef DBITEM_SET_H
29#include <dbitem_set.h>
30#endif
31#ifndef ITEMS_H
32#include <items.h>
33#endif
34
35#define re_assert(cond) arb_assert(cond)
36
37
38namespace RefEntries {
39
40    typedef ARB_ERROR (*referred_item_handler)(GBDATA *gb_main, const DBItemSet& referred);                // called with all referred items
41
42    class RefSelector : virtual Noncopyable {
43        char *field; // name of field containing references
44        char *aci;   // postprocess expression for field-content
45
46        bool error_if_field_missing;
47        bool error_if_ref_unknown;
48    public:
49        RefSelector(const char *field_, const char *aci_, bool error_if_field_missing_, bool error_if_ref_unknown_)
50            : field(strdup(field_)),
51              aci(strdup(aci_)),
52              error_if_field_missing(error_if_field_missing_),
53              error_if_ref_unknown(error_if_ref_unknown_)
54        {}
55        ~RefSelector() {
56            free(aci);
57            free(field);
58        }
59
60        const char *get_refs(ItemSelector& itemtype, GBDATA *gb_item) const;
61        char *filter_refs(const char *refs, GBDATA *gb_item) const;
62
63        bool ignore_unknown_refs() const { return !error_if_ref_unknown; }
64        const char *get_field() const { return field; }
65    };
66
67    class ReferringEntriesHandler {
68        GBDATA        *gb_main;
69        ItemSelector&  itemtype;
70
71    public:
72        ReferringEntriesHandler(GBDATA *gb_main_, ItemSelector& itemtype_)
73            : gb_main(gb_main_),
74              itemtype(itemtype_)
75        {
76            re_assert(&itemtype);
77        }
78
79        GBDATA *get_gbmain() const { return gb_main; }
80        ItemSelector& get_referring_item() const { return itemtype; }
81
82
83        ARB_ERROR with_all_referred_items(GBDATA *gb_item, const RefSelector& refsel, referred_item_handler cb);
84        ARB_ERROR with_all_referred_items(QUERY_RANGE range, const RefSelector& refsel, referred_item_handler cb);
85    };
86
87    // --------------------------
88    //      GUI related below
89
90    typedef void (*client_area_builder)(AW_window *aw_reh); // callback to build client area in RefEntriesHandler window
91
92    AW_window *create_refentries_window(AW_root *awr, ReferringEntriesHandler *reh, const char *window_id, const char *title, const char *help, client_area_builder build_client_area, const char *action, referred_item_handler action_cb);
93    void create_refentries_awars(AW_root *aw_root, AW_default aw_def);
94};
95
96#else
97#error refentries.h included twice
98#endif // REFENTRIES_H
Note: See TracBrowser for help on using the repository browser.