1 | // ==================================================================== // |
---|
2 | // // |
---|
3 | // File : ED4_dump.cxx // |
---|
4 | // Purpose : Contains dump() methods of ED4-classes // |
---|
5 | // // |
---|
6 | // // |
---|
7 | // Coded by Ralf Westram (coder@reallysoft.de) in May 2002 // |
---|
8 | // Copyright Department of Microbiology (Technical University Munich) // |
---|
9 | // // |
---|
10 | // Visit our web site at: http://www.arb-home.de/ // |
---|
11 | // // |
---|
12 | // // |
---|
13 | // ==================================================================== // |
---|
14 | |
---|
15 | #include <arbdb.h> |
---|
16 | #include "ed4_class.hxx" |
---|
17 | |
---|
18 | #ifdef IMPLEMENT_DUMP |
---|
19 | |
---|
20 | #define INDENT_PER_LEVEL 2 |
---|
21 | #define NEXT_INDENT (indent+INDENT_PER_LEVEL) |
---|
22 | #define OUT stdout |
---|
23 | |
---|
24 | static void printProperties(ED4_properties prop) { |
---|
25 | char sep = ' '; |
---|
26 | #define pprop(tag) do { if (prop&PROP_##tag) { fputc(sep, OUT); sep = '|'; fputs(#tag, OUT); } } while(0) |
---|
27 | pprop(IS_MANAGER); |
---|
28 | pprop(IS_TERMINAL); |
---|
29 | pprop(HORIZONTAL); |
---|
30 | pprop(VERTICAL); |
---|
31 | pprop(DYNA_RESIZE); |
---|
32 | pprop(SELECTABLE); |
---|
33 | pprop(DRAGABLE); |
---|
34 | pprop(MOVABLE); |
---|
35 | pprop(IS_HANDLE); |
---|
36 | pprop(CURSOR_ALLOWED); |
---|
37 | pprop(IS_FOLDED); |
---|
38 | pprop(CONSENSUS_RELEVANT); |
---|
39 | pprop(ALIGNMENT_DATA); |
---|
40 | fputc(' ', OUT); |
---|
41 | #undef pprop |
---|
42 | } |
---|
43 | |
---|
44 | static void printLevel(ED4_level level) { |
---|
45 | char sep = ' '; |
---|
46 | #define plev(tag) do { if (level&LEV_##tag) { fputc(sep, OUT); sep = '|'; fputs(#tag, OUT); } } while(0) |
---|
47 | plev(ROOT); |
---|
48 | plev(DEVICE); |
---|
49 | plev(AREA); |
---|
50 | plev(MULTI_SPECIES); |
---|
51 | plev(SPECIES); |
---|
52 | plev(MULTI_SEQUENCE); |
---|
53 | plev(SEQUENCE); |
---|
54 | plev(TREE); |
---|
55 | plev(SPECIES_NAME); |
---|
56 | plev(SEQUENCE_INFO); |
---|
57 | plev(SEQUENCE_STRING); |
---|
58 | plev(ORF); |
---|
59 | plev(SPACER); |
---|
60 | plev(LINE); |
---|
61 | plev(MULTI_NAME); |
---|
62 | plev(NAME_MANAGER); |
---|
63 | plev(GROUP); |
---|
64 | plev(BRACKET); |
---|
65 | plev(PURE_TEXT); |
---|
66 | plev(COL_STAT); |
---|
67 | fputc(' ', OUT); |
---|
68 | #undef plev |
---|
69 | } |
---|
70 | |
---|
71 | static bool at_start_of_line = true; |
---|
72 | inline void print_indent(size_t indent) { |
---|
73 | if (at_start_of_line) while (indent-->0) fputc(' ', OUT); |
---|
74 | } |
---|
75 | inline void print_indented_nocr(size_t indent, const char *text) { |
---|
76 | print_indent(indent); |
---|
77 | fputs(text, OUT); |
---|
78 | at_start_of_line = false; |
---|
79 | } |
---|
80 | inline void print_indented(size_t indent, const char *text) { |
---|
81 | print_indented_nocr(indent, text); |
---|
82 | fputc('\n', OUT); |
---|
83 | at_start_of_line = true; |
---|
84 | } |
---|
85 | |
---|
86 | inline void CR() { fputc('\n', OUT); } |
---|
87 | |
---|
88 | inline void openDump(size_t indent, const char *className, void *thisPtr, bool allow_zero_this = false) { |
---|
89 | print_indented_nocr(indent, className); |
---|
90 | fprintf(OUT, " { "); |
---|
91 | if (thisPtr) { |
---|
92 | fprintf(OUT, "((%s *)%p)\n", className, thisPtr); |
---|
93 | at_start_of_line = true; |
---|
94 | } |
---|
95 | else { |
---|
96 | if (!allow_zero_this) { |
---|
97 | fputs("this=zero-pointer!\n", OUT); |
---|
98 | at_start_of_line = true; |
---|
99 | } |
---|
100 | } |
---|
101 | } |
---|
102 | inline void closeDump(size_t indent) { |
---|
103 | print_indented(indent, "}"); |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | static void dumpProperties(size_t indent, const char *varname, ED4_properties prop) { |
---|
108 | openDump(indent, GBS_global_string("%s(ED4_properties)", varname), NULp, true); |
---|
109 | print_indent(NEXT_INDENT); |
---|
110 | printProperties(prop); |
---|
111 | closeDump(indent); |
---|
112 | } |
---|
113 | |
---|
114 | static void dumpLevel(size_t indent, const char *varname, ED4_level level) { |
---|
115 | openDump(indent, GBS_global_string("%s(ED4_level)", varname), NULp, true); |
---|
116 | print_indent(NEXT_INDENT); |
---|
117 | printLevel(level); |
---|
118 | closeDump(indent); |
---|
119 | } |
---|
120 | |
---|
121 | // ========================================================================================= |
---|
122 | // ED4_base |
---|
123 | |
---|
124 | void ED4_base::dump_base(size_t indent) const { |
---|
125 | openDump(indent, "ED4_Base", (void*)this); |
---|
126 | |
---|
127 | spec.dump(NEXT_INDENT); |
---|
128 | print_indented(NEXT_INDENT, GBS_global_string("id = '%s'", id)); |
---|
129 | print_indented(NEXT_INDENT, GBS_global_string("parent = %p", parent)); |
---|
130 | dumpProperties(NEXT_INDENT, "dynamic_prop", dynamic_prop); |
---|
131 | |
---|
132 | closeDump(indent); |
---|
133 | } |
---|
134 | |
---|
135 | // ========================================================================================= |
---|
136 | // ED4_container |
---|
137 | |
---|
138 | void ED4_container::dump_container(size_t indent) const { |
---|
139 | openDump(indent, "ED4_container", (void*)this); |
---|
140 | for (ED4_index i=0; i<members(); i++) { |
---|
141 | member(i)->dump(NEXT_INDENT); |
---|
142 | } |
---|
143 | closeDump(indent); |
---|
144 | } |
---|
145 | |
---|
146 | // ========================================================================================= |
---|
147 | // managers and terminals |
---|
148 | |
---|
149 | void ED4_manager::dump_base(size_t indent) const { |
---|
150 | openDump(indent, "ED4_manager", (void*)this); |
---|
151 | ED4_base::dump_base(NEXT_INDENT); |
---|
152 | dump_container(NEXT_INDENT); |
---|
153 | closeDump(indent); |
---|
154 | } |
---|
155 | |
---|
156 | inline const char *readable_ED4_species_type(ED4_species_type type) { |
---|
157 | const char *spec_type = "<invalid>"; |
---|
158 | switch (type) { |
---|
159 | case ED4_SP_CONSENSUS: spec_type = "Consensus"; break; |
---|
160 | case ED4_SP_SAI: spec_type = "SAI"; break; |
---|
161 | case ED4_SP_SPECIES: spec_type = "Species"; break; |
---|
162 | case ED4_SP_NONE: spec_type = "None (invalid!)"; break; |
---|
163 | } |
---|
164 | return spec_type; |
---|
165 | } |
---|
166 | |
---|
167 | void ED4_species_manager::dump(size_t indent) const { |
---|
168 | openDump(indent, "ED4_species_manager", (void*)this); |
---|
169 | ED4_base::dump_base(NEXT_INDENT); |
---|
170 | print_indented(NEXT_INDENT, GBS_global_string("type = %s", readable_ED4_species_type(type))); |
---|
171 | dump_container(NEXT_INDENT); |
---|
172 | closeDump(indent); |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | #define STANDARD_BASE_DUMP_CODE(mytype) do { \ |
---|
177 | openDump(indent, #mytype, (void*)this); \ |
---|
178 | mytype::dump_my_base(NEXT_INDENT); \ |
---|
179 | closeDump(indent); \ |
---|
180 | } while (0) |
---|
181 | |
---|
182 | #define STANDARD_LEAF_DUMP_CODE(mytype) do { \ |
---|
183 | openDump(indent, #mytype, (void*)this); \ |
---|
184 | mytype::dump_my_base(NEXT_INDENT); \ |
---|
185 | closeDump(indent); \ |
---|
186 | } while (0) |
---|
187 | |
---|
188 | |
---|
189 | #define STANDARD_DUMP_BASE(self) void self::dump_base(size_t indent) const { STANDARD_BASE_DUMP_CODE(self); } |
---|
190 | #define STANDARD_DUMP_LEAF(self) void self::dump(size_t indent) const { STANDARD_LEAF_DUMP_CODE(self); } |
---|
191 | |
---|
192 | #define STANDARD_DUMP_MID(self) STANDARD_DUMP_BASE(self); STANDARD_DUMP_LEAF(self) |
---|
193 | |
---|
194 | STANDARD_DUMP_BASE(ED4_abstract_group_manager); |
---|
195 | STANDARD_DUMP_BASE(ED4_abstract_sequence_terminal); |
---|
196 | STANDARD_DUMP_BASE(ED4_terminal); |
---|
197 | STANDARD_DUMP_BASE(ED4_text_terminal); |
---|
198 | |
---|
199 | STANDARD_DUMP_MID(ED4_sequence_terminal); |
---|
200 | |
---|
201 | STANDARD_DUMP_LEAF(ED4_area_manager); |
---|
202 | STANDARD_DUMP_LEAF(ED4_bracket_terminal); |
---|
203 | STANDARD_DUMP_LEAF(ED4_columnStat_terminal); |
---|
204 | STANDARD_DUMP_LEAF(ED4_consensus_sequence_terminal); |
---|
205 | STANDARD_DUMP_LEAF(ED4_device_manager); |
---|
206 | STANDARD_DUMP_LEAF(ED4_group_manager); |
---|
207 | STANDARD_DUMP_LEAF(ED4_line_terminal); |
---|
208 | STANDARD_DUMP_LEAF(ED4_main_manager); |
---|
209 | STANDARD_DUMP_LEAF(ED4_multi_name_manager); |
---|
210 | STANDARD_DUMP_LEAF(ED4_multi_sequence_manager); |
---|
211 | STANDARD_DUMP_LEAF(ED4_multi_species_manager); |
---|
212 | STANDARD_DUMP_LEAF(ED4_name_manager); |
---|
213 | STANDARD_DUMP_LEAF(ED4_orf_terminal); |
---|
214 | STANDARD_DUMP_LEAF(ED4_pure_text_terminal); |
---|
215 | STANDARD_DUMP_LEAF(ED4_root_group_manager); |
---|
216 | STANDARD_DUMP_LEAF(ED4_sequence_info_terminal); |
---|
217 | STANDARD_DUMP_LEAF(ED4_sequence_manager); |
---|
218 | STANDARD_DUMP_LEAF(ED4_spacer_terminal); |
---|
219 | STANDARD_DUMP_LEAF(ED4_species_name_terminal); |
---|
220 | STANDARD_DUMP_LEAF(ED4_tree_terminal); |
---|
221 | STANDARD_DUMP_LEAF(ED4_flag_header_terminal); |
---|
222 | STANDARD_DUMP_LEAF(ED4_flag_terminal); |
---|
223 | |
---|
224 | // ========================================================================================= |
---|
225 | // member structures |
---|
226 | |
---|
227 | void ED4_objspec::dump(size_t indent) const { |
---|
228 | openDump(indent, "ED4_objspec", (void*)this); |
---|
229 | dumpProperties(NEXT_INDENT, "static_prop", static_prop); |
---|
230 | dumpLevel(NEXT_INDENT, "level", level); |
---|
231 | dumpLevel(NEXT_INDENT, "allowed_children", allowed_children); |
---|
232 | dumpLevel(NEXT_INDENT, "used_children", used_children); |
---|
233 | #if 0 |
---|
234 | dumpLevel(NEXT_INDENT, "allowed_descendants", allowed_descendants); |
---|
235 | dumpLevel(NEXT_INDENT, "possible_descendants", possible_descendants); |
---|
236 | dumpLevel(NEXT_INDENT, "handled_level", handled_level); |
---|
237 | dumpLevel(NEXT_INDENT, "restriction_level", restriction_level); |
---|
238 | #endif |
---|
239 | closeDump(indent); |
---|
240 | } |
---|
241 | |
---|
242 | void ED4_extension::dump(size_t indent) const { |
---|
243 | openDump(indent, "ED4_extension", (void*)this); |
---|
244 | print_indented(NEXT_INDENT, GBS_global_string("position[0] = %f (x)", position[0])); |
---|
245 | print_indented(NEXT_INDENT, GBS_global_string("position[1] = %f (y)", position[1])); |
---|
246 | print_indented(NEXT_INDENT, GBS_global_string("size[0] = %f (x)", size[0])); |
---|
247 | print_indented(NEXT_INDENT, GBS_global_string("size[1] = %f (y)", size[1])); |
---|
248 | print_indented(NEXT_INDENT, GBS_global_string("y_folded = %li", y_folded)); |
---|
249 | closeDump(indent); |
---|
250 | } |
---|
251 | void ED4_update_info::dump(size_t indent) const { |
---|
252 | openDump(indent, "ED4_update_info", (void*)this); |
---|
253 | print_indented(NEXT_INDENT, GBS_global_string("resize = %u", resize)); |
---|
254 | print_indented(NEXT_INDENT, GBS_global_string("refresh = %u", refresh)); |
---|
255 | print_indented(NEXT_INDENT, GBS_global_string("clear_at_refresh = %u", clear_at_refresh)); |
---|
256 | print_indented(NEXT_INDENT, GBS_global_string("linked_to_folding_line = %u", linked_to_folding_line)); |
---|
257 | print_indented(NEXT_INDENT, GBS_global_string("linked_to_scrolled_rectangle = %u", linked_to_scrolled_rectangle)); |
---|
258 | print_indented(NEXT_INDENT, GBS_global_string("refresh_horizontal_scrolling = %u", refresh_horizontal_scrolling)); |
---|
259 | print_indented(NEXT_INDENT, GBS_global_string("delete_requested = %u", delete_requested)); |
---|
260 | print_indented(NEXT_INDENT, GBS_global_string("update_requested = %u", update_requested)); |
---|
261 | closeDump(indent); |
---|
262 | } |
---|
263 | |
---|
264 | #endif |
---|
265 | |
---|
266 | |
---|
267 | |
---|