libwreport 2.1
|
00001 /* 00002 * wreport/bulletin/internals - Bulletin implementation helpers 00003 * 00004 * Copyright (C) 2005--2011 ARPA-SIM <urpsim@smr.arpa.emr.it> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * Author: Enrico Zini <enrico@enricozini.com> 00020 */ 00021 00022 #ifndef WREPORT_BULLETIN_INTERNALS_H 00023 #define WREPORT_BULLETIN_INTERNALS_H 00024 00025 #include <wreport/varinfo.h> 00026 #include <wreport/opcode.h> 00027 #include <vector> 00028 00029 namespace wreport { 00030 struct Var; 00031 struct Subset; 00032 struct Bulletin; 00033 00034 namespace bulletin { 00035 00039 struct Bitmap 00040 { 00042 const Var* bitmap; 00043 00048 std::vector<unsigned> refs; 00049 00056 std::vector<unsigned>::const_reverse_iterator iter; 00057 00069 unsigned old_anchor; 00070 00071 Bitmap(); 00072 ~Bitmap(); 00073 00078 void reset(); 00079 00091 void init(const Var& bitmap, const Subset& subset, unsigned anchor); 00092 00097 bool eob() const; 00098 00103 unsigned next(); 00104 }; 00105 00110 struct Visitor : public opcode::Visitor 00111 { 00113 const Vartable* btable; 00114 00116 const Subset* current_subset; 00117 00119 Bitmap bitmap; 00120 00122 int c_scale_change; 00123 00125 int c_width_change; 00126 00131 int c_string_len_override; 00132 00137 int c04_bits; 00138 00140 int c04_meaning; 00141 00143 Varcode want_bitmap; 00144 00151 unsigned data_pos; 00152 00153 00154 Visitor(); 00155 virtual ~Visitor(); 00156 00161 Varinfo get_varinfo(Varcode code); 00162 00164 virtual void do_start_subset(unsigned subset_no, const Subset& current_subset); 00165 00167 virtual void do_start_repetition(unsigned idx); 00168 00173 virtual void do_associated_field(unsigned bit_count, unsigned significance) = 0; 00174 00179 virtual void do_attr(Varinfo info, unsigned var_pos, Varcode attr_code) = 0; 00180 00184 virtual void do_var(Varinfo info) = 0; 00185 00196 virtual const Var& do_semantic_var(Varinfo info) = 0; 00197 00203 virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops) = 0; 00204 00208 virtual void do_char_data(Varcode code) = 0; 00209 00211 00212 virtual void b_variable(Varcode code); 00213 virtual void c_modifier(Varcode code); 00214 virtual void c_change_data_width(Varcode code, int change); 00215 virtual void c_change_data_scale(Varcode code, int change); 00216 virtual void c_associated_field(Varcode code, Varcode sig_code, unsigned nbits); 00217 virtual void c_char_data(Varcode code); 00218 virtual void c_char_data_override(Varcode code, unsigned new_length); 00219 virtual void c_quality_information_bitmap(Varcode code); 00220 virtual void c_substituted_value_bitmap(Varcode code); 00221 virtual void c_substituted_value(Varcode code); 00222 virtual void c_local_descriptor(Varcode code, Varcode desc_code, unsigned nbits); 00223 virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops); 00225 }; 00226 00232 struct BaseVisitor : public Visitor 00233 { 00235 Bulletin& bulletin; 00237 unsigned current_subset_no; 00239 unsigned current_var; 00240 00242 BaseVisitor(Bulletin& bulletin); 00243 00245 Var& get_var(); 00247 Var& get_var(unsigned var_pos) const; 00248 00249 virtual void do_start_subset(unsigned subset_no, const Subset& current_subset); 00250 virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops); 00251 }; 00252 00258 struct ConstBaseVisitor : public Visitor 00259 { 00261 const Bulletin& bulletin; 00263 unsigned current_subset_no; 00265 unsigned current_var; 00266 00268 ConstBaseVisitor(const Bulletin& bulletin); 00269 00271 const Var& get_var(); 00273 const Var& get_var(unsigned var_pos) const; 00274 00275 virtual void do_start_subset(unsigned subset_no, const Subset& current_subset); 00276 virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops); 00277 }; 00278 00279 } 00280 } 00281 00282 #endif