source: branches/species/PHYLO/phylo.hxx

Last change on this file was 19654, checked in by westram, 5 weeks ago
  • reintegrates 'macros' into 'trunk'
    • improves program termination (#867)
      • introduces MacroExitor classes
        • handles confirmation (to quit)
        • waits for macros to finish, then exits w/o confirmation
        • provides specialized termination for different programs via derived classes
          • has been implemented for "normal" arb and merge-tool.
      • introduces ARB_disconnect_from_db
        • generalizes code to terminate all interconnections between GUI, database and macro-ability
        • allow to install atdisconnect-callbacks
          • usable by modules operating on a database; allow to inform module that database will vanish.
        • now used by all arb applications to disconnect from all their database(s), except the properties.
    • fixes some broken behavior
      • merge-tool
        • crashed when quitting via macro
        • wrong restarts, if originally started with arguments,
      • importer
        • failed to record/playback macros
        • crashed in modules operating on the temporary import database
      • database browser
        • crashed on disappearing database
  • adds: log:branches/macros@19620:19653
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : phylo.hxx                                         //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef PHYLO_HXX
12#define PHYLO_HXX
13
14#ifndef PH_FILTER_HXX
15#include "PH_filter.hxx"
16#endif
17#ifndef AW_BASE_HXX
18#include <aw_base.hxx>
19#endif
20#ifndef ARB_ASSERT_H
21#include <arb_assert.h>
22#endif
23
24#define ph_assert(cond) arb_assert(cond)
25
26#define AWAR_PHYLO_ALIGNMENT     "tmp/phyl/alignment"
27#define AWAR_PHYLO_FILTER_FILTER "phyl/filter/filter"
28
29#define AWAR_PHYLO_FILTER_STARTCOL "phyl/filter/startcol"
30#define AWAR_PHYLO_FILTER_STOPCOL  "phyl/filter/stopcol"
31#define AWAR_PHYLO_FILTER_MINHOM   "phyl/filter/minhom"
32#define AWAR_PHYLO_FILTER_MAXHOM   "phyl/filter/maxhom"
33#define AWAR_PHYLO_FILTER_DOT      "phyl/filter/point"
34#define AWAR_PHYLO_FILTER_MINUS    "phyl/filter/minus"
35#define AWAR_PHYLO_FILTER_AMBIG    "phyl/filter/rest"
36#define AWAR_PHYLO_FILTER_LOWER    "phyl/filter/lower"
37#define AWAR_PHYLO_FILTER_AUTOCALC "phyl/filter/autocalc"
38
39#define AWAR_PHYLO_MARKERLINENAME "tmp/phylo/markerlinename"
40
41enum FilterMode {
42    DONT_COUNT,
43    SKIP_COLUMN_IF_MAX,
44    SKIP_COLUMN_IF_OCCUR,
45    COUNT_DONT_USE_MAX,
46    TREAT_AS_UPPERCASE,
47    TREAT_AS_REGULAR,
48
49    // Note: enum values are saved in properties (do not modify w/o need!)
50    // update on changes: PH_main.cxx@filter_text
51};
52const int FILTER_MODES = TREAT_AS_REGULAR+1;
53
54
55#define PH_DB_CACHE_SIZE    2000000
56
57enum {
58    PH_GC_SEQUENCE,
59    PH_GC_MARKER,
60    PH_GC_NOT_MARKER,
61    PH_GC_DRAG
62};
63
64enum {
65    PH_GC_BOTTOM_TEXT,
66    PH_GC_BOTTOM_DRAG
67};
68
69void       PH_create_filter_variables(AW_root *aw_root, AW_default default_file, GBDATA *gb_main);
70AW_window *PH_create_filter_window(AW_root *aw_root);
71
72enum display_type {
73    DISP_NONE,    // initial
74    DISP_SPECIES, // after startup, filter not calculated yet
75    DISP_FILTER,  // after filter has been calculated
76};
77
78// ---------------------------
79//      class definitions
80
81class PH_root : virtual Noncopyable {
82    char        *use;
83    GBDATA      *gb_main;
84
85    static PH_root *SINGLETON;
86
87public:
88
89    PH_root() :
90        use(NULp),
91        gb_main(NULp)
92    {
93        ph_assert(!SINGLETON);
94        SINGLETON = this;
95    }
96    ~PH_root() {
97        ph_assert(this == SINGLETON);
98        SINGLETON = NULp;
99        free(use);
100    }
101
102    GB_ERROR open(const char *db_server);
103    GBDATA *get_gb_main() const { ph_assert(gb_main); return gb_main; }
104
105    void disconnect_from_db(AW_root *aw_root);
106};
107
108
109class PHDATA : virtual Noncopyable {
110    // connection to database
111    // pointers to all elements and important values of the database
112
113    struct PHENTRY : virtual Noncopyable {
114        unsigned int  key;
115        char         *name;
116        char         *full_name;
117        GBDATA       *gb_species_data_ptr;
118        PHENTRY      *next;
119        PHENTRY      *prev;
120
121        PHENTRY() :
122            key(0),
123            name(NULp),
124            full_name(NULp),
125            gb_species_data_ptr(NULp),
126            next(NULp),
127            prev(NULp)
128        {}
129
130        ~PHENTRY() {
131            ph_assert(0); // @@@ why not called?
132        }
133    };
134
135    unsigned int last_key_number;
136    long         seq_len;
137
138    AW_root *aw_root; // only link
139    PH_root *ph_root; // only link
140
141    PHENTRY *entries;
142
143    char *unload();
144
145public:
146    GBDATA *get_gb_main() { return ph_root->get_gb_main(); }
147
148    char *use;               // @@@ elim (PH_root has same field)
149
150    PHENTRY      **hash_elements;
151    unsigned int   nentries;                        // total number of entries
152
153    static PHDATA *ROOT;                            // 'global' pointer
154
155    float      *markerline;
156
157    PHDATA(AW_root *aw_root_, PH_root *ph_root_) :
158        last_key_number(0),
159        seq_len(0),
160        aw_root(aw_root_),
161        ph_root(ph_root_),
162        entries(NULp),
163        use(NULp),
164        hash_elements(NULp),
165        nentries(0),
166        markerline(NULp)
167    {}
168    ~PHDATA() {
169        unload();
170    }
171
172    char *load(char*& use); // open database and get pointers to it
173
174    long get_seq_len() { return seq_len; }
175};
176
177#else
178#error phylo.hxx included twice
179#endif // PHYLO_HXX
180
Note: See TracBrowser for help on using the repository browser.