source: tags/arb_5.1/EDIT4/ED4_dump.cxx

Last change on this file was 5675, checked in by westram, 15 years ago
  • removed automatic timestamps (the best they were good for, were vc-conflicts)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 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 <cstdio>
16#include <arbdb.h>
17
18#include <aw_window.hxx>
19
20#include "ed4_class.hxx"
21
22#ifdef IMPLEMENT_DUMP
23
24#define INDENT_PER_LEVEL 2
25#define NEXT_INDENT      (indent+INDENT_PER_LEVEL)
26#define OUT              stdout
27
28// ----------------------------------------------------------
29//      static void printProperties(ED4_properties prop)
30// ----------------------------------------------------------
31static void printProperties(ED4_properties prop) {
32#define pprop(tag) if (prop&ED4_P_##tag) fputs(#tag"|", OUT)
33    pprop(IS_MANAGER);
34    pprop(IS_TERMINAL);
35    pprop(HORIZONTAL);
36    pprop(VERTICAL);
37    pprop(TMP);
38    pprop(SELECTABLE);
39    pprop(DRAGABLE);
40    pprop(MOVABLE);
41    pprop(IS_HANDLE);
42    pprop(CURSOR_ALLOWED);
43    pprop(IS_FOLDED);
44    pprop(CONSENSUS_RELEVANT);
45#undef pprop
46}
47
48// -------------------------------------------------
49//      static void printLevel(ED4_level level)
50// -------------------------------------------------
51static void printLevel(ED4_level level) {
52#define plev(tag) if (level&ED4_L_##tag) fputs(#tag"|", OUT)
53    plev(ROOT);
54    plev(DEVICE);
55    plev(AREA);
56    plev(MULTI_SPECIES);
57    plev(SPECIES);
58    plev(MULTI_SEQUENCE);
59    plev(SEQUENCE);
60    plev(TREE);
61    plev(SPECIES_NAME);
62    plev(SEQUENCE_INFO);
63    plev(SEQUENCE_STRING);
64    plev(SPACER);
65    plev(LINE);
66    plev(MULTI_NAME);
67    plev(NAME_MANAGER);
68    plev(GROUP);
69    plev(BRACKET);
70    plev(PURE_TEXT);
71    plev(COL_STAT);
72#undef plev
73}
74
75inline void print_indent(size_t indent) {
76    while (indent-->0) fputc(' ', OUT);
77}
78inline void print_indented_nocr(size_t indent, const char *text) {
79    print_indent(indent);
80    fputs(text, OUT);
81}
82inline void print_indented(size_t indent, const char *text) {
83    print_indented_nocr(indent, text);
84    fputc('\n', OUT);
85}
86
87inline void CR() { fputc('\n', OUT); }
88
89inline void openDump(size_t indent, const char *className, void *thisPtr, bool allow_zero_this = false) {
90    print_indented_nocr(indent, className);
91    fprintf(OUT, " { ");
92    if (thisPtr) {
93        fprintf(OUT, "((%s *)%p)\n", className, thisPtr);
94    }
95    else {
96        if (!allow_zero_this) {
97            fputs("this=zero-pointer!\n", OUT);
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("ED4_properties (%s)", 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("ED4_level (%s)", 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    print_indented(NEXT_INDENT, GBS_global_string("my_species_pointer=%p", get_species_pointer()));
126    print_indented(NEXT_INDENT, GBS_global_string("lastXpos          =%f", lastXpos));
127    print_indented(NEXT_INDENT, GBS_global_string("lastYpos          =%f", lastYpos));
128    print_indented(NEXT_INDENT, GBS_global_string("timestamp         =%i", timestamp));
129    print_indented(NEXT_INDENT, GBS_global_string("parent            =%p", parent));
130    print_indented(NEXT_INDENT, GBS_global_string("id                ='%s'", id));
131    print_indented(NEXT_INDENT, GBS_global_string("index             =%li", index));
132    print_indented(NEXT_INDENT, GBS_global_string("width_link        =%p", width_link));
133    print_indented(NEXT_INDENT, GBS_global_string("height_link       =%p", height_link));
134    print_indented(NEXT_INDENT, GBS_global_string("flag.hidden       =%i", flag.hidden));
135    print_indented(NEXT_INDENT, GBS_global_string("flag.is_consensus =%i", flag.is_consensus));
136    print_indented(NEXT_INDENT, GBS_global_string("flag.is_SAI       =%i", flag.is_SAI));
137
138    if (spec) spec->dump(NEXT_INDENT);
139    dumpProperties(NEXT_INDENT, "dynamic_prop", dynamic_prop);
140    extension.dump(NEXT_INDENT);
141    update_info.dump(NEXT_INDENT);
142
143    closeDump(indent);
144}
145
146// =========================================================================================
147// ED4_manager's
148
149void ED4_manager::dump(size_t indent) const {
150    openDump(indent, "ED4_Manager", (void*)this);
151    dump_base(NEXT_INDENT);
152    children->dump(NEXT_INDENT);
153    closeDump(indent);
154}
155
156void ED4_members::dump(size_t indent) const {
157    openDump(indent, "ED4_members", (void*)this);
158    for (ED4_index i=0; i<members(); i++) {
159        member(i)->dump(NEXT_INDENT);
160    }
161    closeDump(indent);
162}
163
164#define DUMP_MANAGER(mytype) do {               \
165    openDump(indent, #mytype, (void*)this);     \
166    ED4_manager::dump(NEXT_INDENT);             \
167    closeDump(indent);                          \
168} while (0)
169
170void ED4_area_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_area_manager); }
171void ED4_device_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_device_manager); }
172void ED4_group_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_group_manager); }
173void ED4_main_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_main_manager); }
174void ED4_multi_name_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_multi_name_manager); }
175void ED4_multi_sequence_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_multi_sequence_manager); }
176void ED4_multi_species_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_multi_species_manager); }
177void ED4_name_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_name_manager); }
178void ED4_sequence_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_sequence_manager); }
179void ED4_species_manager::dump(size_t indent) const { DUMP_MANAGER(ED4_species_manager); }
180
181#undef DUMP_MANAGER
182
183// =========================================================================================
184// ED4_terminal's
185
186void ED4_terminal::dump(size_t indent) const {
187    openDump(indent, "ED4_terminal", (void*)this);
188    dump_base(NEXT_INDENT);
189    closeDump(indent);
190}
191
192#define DUMP_TERMINAL(mytype) do {               \
193    openDump(indent, #mytype, (void*)this);     \
194    ED4_terminal::dump(NEXT_INDENT);             \
195    closeDump(indent);                          \
196} while (0)
197
198void ED4_bracket_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_bracket_terminal); }
199void ED4_columnStat_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_columnStat_terminal); }
200void ED4_consensus_sequence_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_consensus_sequence_terminal); }
201void ED4_line_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_line_terminal); }
202void ED4_pure_text_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_pure_text_terminal); }
203void ED4_sequence_info_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_sequence_info_terminal); }
204void ED4_sequence_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_sequence_terminal); }
205void ED4_spacer_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_spacer_terminal); }
206void ED4_species_name_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_species_name_terminal); }
207void ED4_text_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_text_terminal); }
208void ED4_tree_terminal::dump(size_t indent) const { DUMP_TERMINAL(ED4_tree_terminal); }
209
210#undef DUMP_TERMINAL
211
212// =========================================================================================
213// member structures
214
215void ED4_object_specification::dump(size_t indent) const {
216    openDump(indent, "ED4_object_specification", (void*)this);
217    dumpProperties(NEXT_INDENT, "static_prop", static_prop);
218    dumpLevel(NEXT_INDENT, "level", level);
219    dumpLevel(NEXT_INDENT, "allowed_children", allowed_children);
220    dumpLevel(NEXT_INDENT, "handled_level", handled_level);
221    dumpLevel(NEXT_INDENT, "restriction_level", restriction_level);
222    print_indented(NEXT_INDENT, GBS_global_string("justification       =%f", justification));
223    closeDump(indent);
224}
225
226void ED4_extension::dump(size_t indent) const {
227    openDump(indent, "ED4_extension", (void*)this);
228    print_indented(NEXT_INDENT, GBS_global_string("position[0] = %f (x)", position[0]));
229    print_indented(NEXT_INDENT, GBS_global_string("position[1] = %f (y)", position[1]));
230    print_indented(NEXT_INDENT, GBS_global_string("size[0]     = %f (x)", size[0]));
231    print_indented(NEXT_INDENT, GBS_global_string("size[1]     = %f (y)", size[1]));
232    print_indented(NEXT_INDENT, GBS_global_string("y_folded    = %li", y_folded));
233    closeDump(indent);
234}
235void ED4_update_info::dump(size_t indent) const {
236    openDump(indent, "ED4_update_info", (void*)this);
237    print_indented(NEXT_INDENT, GBS_global_string("resize                         = %u", resize));
238    print_indented(NEXT_INDENT, GBS_global_string("refresh                        = %u", refresh));
239    print_indented(NEXT_INDENT, GBS_global_string("clear_at_refresh               = %u", clear_at_refresh));
240    print_indented(NEXT_INDENT, GBS_global_string("linked_to_folding_line         = %u", linked_to_folding_line));
241    print_indented(NEXT_INDENT, GBS_global_string("linked_to_scrolled_rectangle   = %u", linked_to_scrolled_rectangle));
242    print_indented(NEXT_INDENT, GBS_global_string("refresh_horizontal_scrolling   = %u", refresh_horizontal_scrolling));
243    print_indented(NEXT_INDENT, GBS_global_string("delete_requested               = %u", delete_requested));
244    closeDump(indent);
245}
246
247#endif
248
249
250
Note: See TracBrowser for help on using the repository browser.