source: branches/profile/EDIT4/ED4_dump.cxx

Last change on this file was 9908, checked in by epruesse, 7 years ago

prepare for removal of AW_VARIABLE_TYPE in GTK branch

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 KB
Line 
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
24static void printProperties(ED4_properties prop) {
25    char sep = ' ';
26#define pprop(tag) do { if (prop&ED4_P_##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(TMP);
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    fputc(' ', OUT);
40#undef pprop
41}
42
43static void printLevel(ED4_level level) {
44    char sep = ' ';
45#define plev(tag) do { if (level&ED4_L_##tag) { fputc(sep, OUT); sep = '|'; fputs(#tag, OUT); } } while(0)
46    plev(ROOT);
47    plev(DEVICE);
48    plev(AREA);
49    plev(MULTI_SPECIES);
50    plev(SPECIES);
51    plev(MULTI_SEQUENCE);
52    plev(SEQUENCE);
53    plev(TREE);
54    plev(SPECIES_NAME);
55    plev(SEQUENCE_INFO);
56    plev(SEQUENCE_STRING);
57    plev(ORF);
58    plev(SPACER);
59    plev(LINE);
60    plev(MULTI_NAME);
61    plev(NAME_MANAGER);
62    plev(GROUP);
63    plev(BRACKET);
64    plev(PURE_TEXT);
65    plev(COL_STAT);
66    fputc(' ', OUT);
67#undef plev
68}
69
70static bool at_start_of_line = true;
71inline void print_indent(size_t indent) {
72    if (at_start_of_line) while (indent-->0) fputc(' ', OUT);
73}
74inline void print_indented_nocr(size_t indent, const char *text) {
75    print_indent(indent);
76    fputs(text, OUT);
77    at_start_of_line = false;
78}
79inline void print_indented(size_t indent, const char *text) {
80    print_indented_nocr(indent, text);
81    fputc('\n', OUT);
82    at_start_of_line = true;
83}
84
85inline void CR() { fputc('\n', OUT); }
86
87inline void openDump(size_t indent, const char *className, void *thisPtr, bool allow_zero_this = false) {
88    print_indented_nocr(indent, className);
89    fprintf(OUT, " { ");
90    if (thisPtr) {
91        fprintf(OUT, "((%s *)%p)\n", className, thisPtr);
92        at_start_of_line = true;
93    }
94    else {
95        if (!allow_zero_this) {
96            fputs("this=zero-pointer!\n", OUT);
97            at_start_of_line = true;
98        }
99    }
100}
101inline void closeDump(size_t indent) {
102    print_indented(indent, "}");
103}
104
105
106static void dumpProperties(size_t indent, const char *varname, ED4_properties prop) {
107    openDump(indent, GBS_global_string("%s(ED4_properties)", varname), 0, true);
108    print_indent(NEXT_INDENT);
109    printProperties(prop);
110    closeDump(indent);
111}
112
113static void dumpLevel(size_t indent, const char *varname, ED4_level level) {
114    openDump(indent, GBS_global_string("%s(ED4_level)", varname), 0, true);
115    print_indent(NEXT_INDENT);
116    printLevel(level);
117    closeDump(indent);
118}
119
120// =========================================================================================
121// ED4_base
122
123void ED4_base::dump_base(size_t indent) const {
124    openDump(indent, "ED4_Base", (void*)this);
125   
126    spec.dump(NEXT_INDENT);
127    print_indented(NEXT_INDENT, GBS_global_string("id                    = '%s'", id));
128    print_indented(NEXT_INDENT, GBS_global_string("parent                = %p", parent));
129
130    closeDump(indent);
131}
132
133// =========================================================================================
134// ED4_members
135
136void ED4_members::dump(size_t indent) const {
137    openDump(indent, "ED4_members", (void*)this);
138    for (ED4_index i=0; i<members(); i++) {
139        member(i)->dump(NEXT_INDENT);
140    }
141    closeDump(indent);
142}
143
144// =========================================================================================
145// managers and terminals
146
147void ED4_manager::dump_base(size_t indent) const {
148    openDump(indent, "ED4_manager", (void*)this);
149    ED4_base::dump_base(NEXT_INDENT);
150    children->dump(NEXT_INDENT);
151    closeDump(indent);
152}
153
154inline const char *readable_ED4_species_type(ED4_species_type type) {
155    const char *spec_type = "<invalid>";
156    switch (type) {
157        case ED4_SP_CONSENSUS: spec_type = "Consensus"; break;
158        case ED4_SP_SAI:       spec_type = "SAI"; break;
159        case ED4_SP_SPECIES:   spec_type = "Species"; break;
160        case ED4_SP_NONE:      spec_type = "None (invalid!)"; break;
161    }
162    return spec_type;
163}
164
165void ED4_species_manager::dump(size_t indent) const {
166    openDump(indent, "ED4_species_manager", (void*)this);
167    ED4_base::dump_base(NEXT_INDENT);
168    print_indented(NEXT_INDENT, GBS_global_string("type                   = %s", readable_ED4_species_type(type)));
169    children->dump(NEXT_INDENT);
170    closeDump(indent);
171}
172
173
174#define STANDARD_BASE_DUMP_CODE(mytype) do {      \
175        openDump(indent, #mytype, (void*)this); \
176        mytype::dump_my_base(NEXT_INDENT);      \
177        closeDump(indent);                      \
178    } while (0)
179   
180#define STANDARD_LEAF_DUMP_CODE(mytype) do {           \
181        openDump(indent, #mytype, (void*)this); \
182        mytype::dump_my_base(NEXT_INDENT);        \
183        closeDump(indent);                      \
184    } while (0)
185
186
187#define STANDARD_DUMP_BASE(self) void self::dump_base(size_t indent) const { STANDARD_BASE_DUMP_CODE(self); }
188#define STANDARD_DUMP_LEAF(self) void self::dump(size_t indent) const { STANDARD_LEAF_DUMP_CODE(self); }
189
190#define STANDARD_DUMP_MID(self) STANDARD_DUMP_BASE(self); STANDARD_DUMP_LEAF(self)
191
192STANDARD_DUMP_BASE(ED4_abstract_group_manager);
193STANDARD_DUMP_BASE(ED4_abstract_sequence_terminal);
194STANDARD_DUMP_BASE(ED4_terminal);
195STANDARD_DUMP_BASE(ED4_text_terminal);
196
197STANDARD_DUMP_MID(ED4_sequence_terminal);
198
199STANDARD_DUMP_LEAF(ED4_area_manager);
200STANDARD_DUMP_LEAF(ED4_bracket_terminal);
201STANDARD_DUMP_LEAF(ED4_columnStat_terminal);
202STANDARD_DUMP_LEAF(ED4_consensus_sequence_terminal);
203STANDARD_DUMP_LEAF(ED4_device_manager);
204STANDARD_DUMP_LEAF(ED4_group_manager);
205STANDARD_DUMP_LEAF(ED4_line_terminal);
206STANDARD_DUMP_LEAF(ED4_main_manager);
207STANDARD_DUMP_LEAF(ED4_multi_name_manager);
208STANDARD_DUMP_LEAF(ED4_multi_sequence_manager);
209STANDARD_DUMP_LEAF(ED4_multi_species_manager);
210STANDARD_DUMP_LEAF(ED4_name_manager);
211STANDARD_DUMP_LEAF(ED4_orf_terminal);
212STANDARD_DUMP_LEAF(ED4_pure_text_terminal);
213STANDARD_DUMP_LEAF(ED4_root_group_manager);
214STANDARD_DUMP_LEAF(ED4_sequence_info_terminal);
215STANDARD_DUMP_LEAF(ED4_sequence_manager);
216STANDARD_DUMP_LEAF(ED4_spacer_terminal);
217STANDARD_DUMP_LEAF(ED4_species_name_terminal);
218STANDARD_DUMP_LEAF(ED4_tree_terminal);
219
220// =========================================================================================
221// member structures
222
223void ED4_objspec::dump(size_t indent) const {
224    openDump(indent, "ED4_objspec", (void*)this);
225    dumpProperties(NEXT_INDENT, "static_prop", static_prop);
226    dumpLevel(NEXT_INDENT, "level",                level);
227    dumpLevel(NEXT_INDENT, "allowed_children",     allowed_children);
228    dumpLevel(NEXT_INDENT, "used_children",        used_children);
229    dumpLevel(NEXT_INDENT, "allowed_descendants",  allowed_descendants);
230    dumpLevel(NEXT_INDENT, "possible_descendants", possible_descendants);
231    dumpLevel(NEXT_INDENT, "handled_level",        handled_level);
232    dumpLevel(NEXT_INDENT, "restriction_level",    restriction_level);
233    closeDump(indent);
234}
235
236void ED4_extension::dump(size_t indent) const {
237    openDump(indent, "ED4_extension", (void*)this);
238    print_indented(NEXT_INDENT, GBS_global_string("position[0] = %f (x)", position[0]));
239    print_indented(NEXT_INDENT, GBS_global_string("position[1] = %f (y)", position[1]));
240    print_indented(NEXT_INDENT, GBS_global_string("size[0]     = %f (x)", size[0]));
241    print_indented(NEXT_INDENT, GBS_global_string("size[1]     = %f (y)", size[1]));
242    print_indented(NEXT_INDENT, GBS_global_string("y_folded    = %li", y_folded));
243    closeDump(indent);
244}
245void ED4_update_info::dump(size_t indent) const {
246    openDump(indent, "ED4_update_info", (void*)this);
247    print_indented(NEXT_INDENT, GBS_global_string("resize                         = %u", resize));
248    print_indented(NEXT_INDENT, GBS_global_string("refresh                        = %u", refresh));
249    print_indented(NEXT_INDENT, GBS_global_string("clear_at_refresh               = %u", clear_at_refresh));
250    print_indented(NEXT_INDENT, GBS_global_string("linked_to_folding_line         = %u", linked_to_folding_line));
251    print_indented(NEXT_INDENT, GBS_global_string("linked_to_scrolled_rectangle   = %u", linked_to_scrolled_rectangle));
252    print_indented(NEXT_INDENT, GBS_global_string("refresh_horizontal_scrolling   = %u", refresh_horizontal_scrolling));
253    print_indented(NEXT_INDENT, GBS_global_string("delete_requested               = %u", delete_requested));
254    print_indented(NEXT_INDENT, GBS_global_string("update_requested               = %u", update_requested));
255    closeDump(indent);
256}
257
258#endif
259
260
261
Note: See TracBrowser for help on using the repository browser.