libwreport  2.4
internals.h
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 
00173     virtual void do_start_repetition(unsigned idx);
00174 
00179     virtual void do_associated_field(unsigned bit_count, unsigned significance) = 0;
00180 
00185     virtual void do_attr(Varinfo info, unsigned var_pos, Varcode attr_code) = 0;
00186 
00190     virtual void do_var(Varinfo info) = 0;
00191 
00202     virtual const Var& do_semantic_var(Varinfo info) = 0;
00203 
00219     virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops) = 0;
00220 
00224     virtual void do_char_data(Varcode code) = 0;
00225 
00227 
00228     virtual void b_variable(Varcode code);
00229     virtual void c_modifier(Varcode code);
00230     virtual void c_change_data_width(Varcode code, int change);
00231     virtual void c_change_data_scale(Varcode code, int change);
00232     virtual void c_associated_field(Varcode code, Varcode sig_code, unsigned nbits);
00233     virtual void c_char_data(Varcode code);
00234     virtual void c_char_data_override(Varcode code, unsigned new_length);
00235     virtual void c_quality_information_bitmap(Varcode code);
00236     virtual void c_substituted_value_bitmap(Varcode code);
00237     virtual void c_substituted_value(Varcode code);
00238     virtual void c_local_descriptor(Varcode code, Varcode desc_code, unsigned nbits);
00239     virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops);
00241 };
00242 
00248 struct BaseVisitor : public Visitor
00249 {
00251     Bulletin& bulletin;
00253     unsigned current_subset_no;
00255     unsigned current_var;
00256 
00258     BaseVisitor(Bulletin& bulletin);
00259 
00261     Var& get_var();
00263     Var& get_var(unsigned var_pos) const;
00264 
00265     virtual void do_start_subset(unsigned subset_no, const Subset& current_subset);
00266     virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops);
00267 };
00268 
00274 struct ConstBaseVisitor : public Visitor
00275 {
00277     const Bulletin& bulletin;
00279     unsigned current_subset_no;
00281     unsigned current_var;
00282 
00284     ConstBaseVisitor(const Bulletin& bulletin);
00285 
00287     const Var& get_var();
00289     const Var& get_var(unsigned var_pos) const;
00290 
00291     virtual void do_start_subset(unsigned subset_no, const Subset& current_subset);
00292     virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops);
00293 };
00294 
00295 }
00296 }
00297 
00298 #endif