| 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 | |
|---|
| 34 | struct AP_STACK_ELEM { |
|---|
| 35 | struct AP_STACK_ELEM * next; |
|---|
| 36 | void * node; |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | class 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 | |
|---|
| 45 | public: |
|---|
| 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 | |
|---|
| 61 | struct AP_list_elem { |
|---|
| 62 | AP_list_elem * next; |
|---|
| 63 | AP_list_elem * prev; |
|---|
| 64 | void * node; |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | class 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); |
|---|
| 72 | public: |
|---|
| 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 | |
|---|
| 90 | class AP_tree_edge; // defined in ap_tree_nlen.hxx |
|---|
| 91 | struct AP_tree_buffer; |
|---|
| 92 | |
|---|
| 93 | struct 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 | |
|---|
| 100 | struct 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 | |
|---|
| 123 | class AP_tree_stack : public AP_STACK { |
|---|
| 124 | public: |
|---|
| 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 | |
|---|
| 134 | class AP_tree_nlen; |
|---|
| 135 | |
|---|
| 136 | class AP_main_stack : public AP_STACK { |
|---|
| 137 | protected: |
|---|
| 138 | unsigned long last_user_buffer; |
|---|
| 139 | public: |
|---|
| 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 | |
|---|
| 149 | class AP_main_list : public AP_LIST { |
|---|
| 150 | public: |
|---|
| 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 |
|---|