source: tags/svn.1.5.4/PARSIMONY/AP_buffer.hxx

Last change on this file was 7623, checked in by westram, 13 years ago
  • merge from dev [7450] [7452] [7456] [7457] [7458] [7459] [7460] [7461] [7464] [7465] [7466] [7467] [7468] [7469] [7482]
    • tweaked compiler options
      • activated -Weffc++
        • postfilter warnings where Scott Meyers' advices are too general.
          • base classes should not always have virtual destructors, since that renders tiny classes useless and
          • members should not always be initialized via initialization list, since that often violates the DRY principle
        • fix gcc's inability to detect that Noncopyable implements a private copy-ctor and op=
        • this slows down complete ARB recompilation by ~5%
    • added -Wold-style-cast (inactive)
    • removed -Wno-non-template-friend added in [7447]
  • postcompile.pl
    • added option —original to show unmodified compiler output
  • declared op= for classes which had a copy-ctor
  • moved op= macros to arbtools.h
  • derived classes containing pointers from Noncopyable (use Noncopyable virtually) or
  • made them copyable if needed (awt_mask_item, KnownDB, Code, AWT_registered_itemtype, GEN_gene, PosGene, PartialSequence, PlugIn, Range, Convaln_exception)
  • other related changes
    • user mask destruction working now
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : AP_buffer.hxx                                     //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef AP_BUFFER_HXX
12#define AP_BUFFER_HXX
13
14#ifndef AP_TREE_HXX
15#include <AP_Tree.hxx>
16#endif
17
18
19/* AP_STACK        dynamischer Stack fuer void *
20 * AP_LIST         allgemeine doppelt verketteten Liste
21 *
22 * -- Pufferstrukturen
23 *
24 * AP_tree_buffer  Struktur die im AP_tree gepuffert wird
25 *
26 * -- spezielle stacks ( um casts zu vermeiden )
27 *
28 * AP_tree_stack   Stack fuer AP_tree_buffer *
29 * AP_main_stack   Stack fuer AP_tree *
30 * AP_main_list    Liste fuer AP_main_buffer
31 */
32
33
34struct AP_STACK_ELEM {
35    struct AP_STACK_ELEM * next;
36    void *                 node;
37};
38
39class AP_STACK : virtual Noncopyable {
40    struct AP_STACK_ELEM * first;
41    struct AP_STACK_ELEM * pointer;
42    unsigned long          stacksize;
43    unsigned long          max_stacksize;
44
45public:
46    AP_STACK();
47    virtual ~AP_STACK();
48
49    void           push(void * element);
50    void          *pop();
51    void           clear();
52    void           get_init();
53    void          *get();
54    void          *get_first();
55    unsigned long  size();
56};
57
58// ----------------
59//      AP_LIST
60
61struct AP_list_elem {
62    AP_list_elem * next;
63    AP_list_elem * prev;
64    void *         node;
65};
66
67class AP_LIST : virtual Noncopyable {
68    unsigned int  list_len;
69    unsigned int  akt;
70    AP_list_elem *first, *last, *pointer;
71    AP_list_elem *element(void * elem);
72public:
73    AP_LIST();
74    virtual ~AP_LIST();
75
76    int   len();
77    int   is_element(void * node);
78    int   eof();
79    void  insert(void * new_one);
80    void  append(void * new_one);
81    void  remove(void * object);
82    void  push(void *elem);
83    void *pop();
84    void  clear();
85};
86
87// ----------------------------------------------------------------
88//      special buffer-structures for AP_tree and AP_tree_edge
89
90class  AP_tree_edge;                                // defined in ap_tree_nlen.hxx
91struct AP_tree_buffer;
92
93struct AP_tree_edge_data
94{
95    AP_FLOAT parsValue[3];                          // the last three parsimony values (0=lowest 2=highest)
96    int      distance;                              // the distance of the last insertion
97};
98
99
100struct AP_tree_buffer {
101    unsigned long  controll;                        // used for internal buffer check
102    unsigned int   count;                           // counts how often the entry is buffered
103    AP_STACK_MODE  mode;
104    AP_sequence   *sequence;
105    AP_FLOAT       mutation_rate;
106    double         leftlen, rightlen;
107    AP_tree       *father;
108    AP_tree       *leftson;
109    AP_tree       *rightson;
110    AP_tree_root  *root;
111    GBDATA        *gb_node;
112
113    int distance;                                   // distance to border (pushed with STRUCTURE!)
114
115    // data from edges:
116    AP_tree_edge      *edge[3];
117    int                edgeIndex[3];
118    AP_tree_edge_data  edgeData[3];
119
120    void print();
121};
122
123class AP_tree_stack : public AP_STACK {
124public:
125    AP_tree_stack() {}
126    virtual ~AP_tree_stack() {}
127    void  push(AP_tree_buffer *value) { AP_STACK::push((void *)value); }
128    AP_tree_buffer * pop() { return (AP_tree_buffer *) AP_STACK::pop(); }
129    AP_tree_buffer * get() { return (AP_tree_buffer *) AP_STACK::get(); }
130    AP_tree_buffer * get_first() { return (AP_tree_buffer *) AP_STACK::get_first(); }
131    void print();
132};
133
134class AP_tree_nlen;
135
136class AP_main_stack : public AP_STACK {
137protected:
138    unsigned long last_user_buffer;
139public:
140    friend class AP_main;
141    void push(AP_tree_nlen *value) { AP_STACK::push((void *)value); }
142    AP_tree_nlen *pop() { return (AP_tree_nlen*)AP_STACK::pop(); }
143    AP_tree_nlen *get() { return (AP_tree_nlen*)AP_STACK::get(); }
144    AP_tree_nlen *get_first() { return (AP_tree_nlen*)AP_STACK::get_first(); }
145    void print();
146};
147
148
149class AP_main_list : public AP_LIST {
150public:
151    AP_main_stack * pop() { return  (AP_main_stack *)AP_LIST::pop(); }
152    void push(AP_main_stack * stack) { AP_LIST::push((void *) stack); }
153    void insert(AP_main_stack * stack) { AP_LIST::insert((void *)stack); }
154    void append(AP_main_stack * stack) { AP_LIST::append((void *)stack); }
155};
156
157#else
158#error AP_buffer.hxx included twice
159#endif // AP_BUFFER_HXX
Note: See TracBrowser for help on using the repository browser.