source: tags/testbuild/PARSIMONY/ap_main.hxx

Last change on this file was 13267, checked in by westram, 10 years ago
  • renamed AP_main::push/pop/clear into remember/revert/accept
  • added convenience wrappers accept_if/revert_if
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : ap_main.hxx                                       //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef AP_MAIN_HXX
12#define AP_MAIN_HXX
13
14#ifndef AP_BUFFER_HXX
15#include "AP_buffer.hxx"
16#endif
17#ifndef PARS_DTREE_HXX
18#include "pars_dtree.hxx"
19#endif
20
21#define AWAR_ALIGNMENT        "tmp/pars/alignment"
22#define AWAR_FILTER_NAME      "tmp/pars/filter/name"
23#define AWAR_FILTER_FILTER    "tmp/pars/filter/filter"
24#define AWAR_FILTER_ALIGNMENT "tmp/pars/filter/alignment"
25#define AWAR_PARSIMONY        "tmp/pars/parsimony"
26#define AWAR_BEST_PARSIMONY   "tmp/pars/best_parsimony"
27#define AWAR_STACKPOINTER     "tmp/pars/stackpointer"
28
29#define AWAR_PARS_TYPE      "pars/pars_type"
30
31enum PARS_pars_type {
32    PARS_WAGNER,
33    PARS_TRANSVERSION
34};
35
36struct PARS_commands {
37    bool add_marked;
38    bool add_selected;
39    bool calc_branch_lengths;
40    bool calc_bootstrap;
41    bool quit;
42
43    PARS_commands()
44        : add_marked(false)
45        , add_selected(false)
46        , calc_branch_lengths(false)
47        , calc_bootstrap(false)
48        , quit(false)
49    {
50    }
51};
52
53class AP_main : virtual Noncopyable {
54    NodeStack             *currFrame;
55    FrameStack             frames;
56    Level                  frameLevel;
57    AWT_graphic_parsimony *agt;       // provides access to tree!
58    StackFrameData         frameData; // saved/restored by push/pop
59    GBDATA                *gb_main;
60
61public:
62    AP_main()
63        : currFrame(NULL),
64          frameLevel(0),
65          agt(NULL),
66          gb_main(NULL)
67    {}
68    ~AP_main() {
69        if (gb_main) GB_close(gb_main);
70        delete currFrame;
71    }
72
73    void set_tree_root(AWT_graphic_parsimony *agt_);
74    AWT_graphic_parsimony *get_graphic_tree() { return agt; }
75    AP_pars_root *get_tree_root() const { return agt->get_tree_root(); }
76
77    DEFINE_DOWNCAST_ACCESSORS(AP_tree_nlen, get_root_node, agt->get_root_node());
78
79    GBDATA *get_gb_main() const {
80        ap_assert(gb_main); // you need to call open() before you can use get_gb_main()
81        return gb_main;
82    }
83    const char *get_aliname() const;
84    Level get_user_push_counter() const { return frameData.user_push_counter; }
85    Level get_frameLevel() const { return frameLevel; }
86
87    GB_ERROR open(const char *db_server);
88
89    void push_node(AP_tree_nlen *node, AP_STACK_MODE);
90
91    void user_push(); // @@@ -> user_remember
92    void user_pop();  // @@@ -> user_revert
93    // @@@ add user_accept
94
95    void remember();
96    void revert();
97    void accept();
98
99    void accept_if(bool cond) { if (cond) accept(); else revert(); }
100    void revert_if(bool cond) { accept_if(!cond); }
101
102#if defined(PROVIDE_PRINT)
103    void print(std::ostream& out);
104    void print2file(const char *file_in_ARBHOME);
105#endif
106};
107
108extern AP_main *ap_main; // @@@ elim
109
110inline AP_tree_nlen *rootNode() {
111    return ap_main->get_root_node();
112}
113
114inline AP_tree_edge *rootEdge() {
115    return rootNode()->get_leftson()->edgeTo(rootNode()->get_rightson());
116}
117
118#else
119#error ap_main.hxx included twice
120#endif // AP_MAIN_HXX
Note: See TracBrowser for help on using the repository browser.