source: tags/cvs_2_svn/EDIT4/ED4_dump.cxx

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