libwreport  2.14
internals.h
1 /*
2  * wreport/bulletin/internals - Bulletin implementation helpers
3  *
4  * Copyright (C) 2005--2011 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef WREPORT_BULLETIN_INTERNALS_H
23 #define WREPORT_BULLETIN_INTERNALS_H
24 
25 #include <wreport/varinfo.h>
26 #include <wreport/opcode.h>
27 #include <vector>
28 
29 namespace wreport {
30 struct Var;
31 struct Subset;
32 struct Bulletin;
33 
34 namespace bulletin {
35 
39 struct Bitmap
40 {
42  const Var* bitmap;
43 
48  std::vector<unsigned> refs;
49 
56  std::vector<unsigned>::const_reverse_iterator iter;
57 
69  unsigned old_anchor;
70 
71  Bitmap();
72  ~Bitmap();
73 
78  void reset();
79 
91  void init(const Var& bitmap, const Subset& subset, unsigned anchor);
92 
97  bool eob() const;
98 
103  unsigned next();
104 };
105 
110 struct Visitor : public opcode::Visitor
111 {
113  const Vartable* btable;
114 
117 
120 
123 
126 
132 
135 
140  int c04_bits;
141 
144 
147 
154  unsigned data_pos;
155 
156 
157  Visitor();
158  virtual ~Visitor();
159 
165 
167  virtual void do_start_subset(unsigned subset_no, const Subset& current_subset);
168 
176  virtual void do_start_repetition(unsigned idx);
177 
182  virtual void do_associated_field(unsigned bit_count, unsigned significance) = 0;
183 
188  virtual void do_attr(Varinfo info, unsigned var_pos, Varcode attr_code) = 0;
189 
193  virtual void do_var(Varinfo info) = 0;
194 
205  virtual const Var& do_semantic_var(Varinfo info) = 0;
206 
222  virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops) = 0;
223 
227  virtual void do_char_data(Varcode code) = 0;
228 
230  virtual void b_variable(Varcode code);
232  virtual void c_modifier(Varcode code);
233  virtual void c_change_data_width(Varcode code, int change);
234  virtual void c_change_data_scale(Varcode code, int change);
235  virtual void c_associated_field(Varcode code, Varcode sig_code, unsigned nbits);
236  virtual void c_char_data(Varcode code);
237  virtual void c_char_data_override(Varcode code, unsigned new_length);
238  virtual void c_quality_information_bitmap(Varcode code);
239  virtual void c_substituted_value_bitmap(Varcode code);
240  virtual void c_substituted_value(Varcode code);
241  virtual void c_local_descriptor(Varcode code, Varcode desc_code, unsigned nbits);
242  virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes& ops);
243  virtual void c_increase_scale_ref_width(Varcode code, int change);
245 };
246 
252 struct BaseVisitor : public Visitor
253 {
259  unsigned current_var;
260 
262  BaseVisitor(Bulletin& bulletin);
263 
265  Var& get_var();
267  Var& get_var(unsigned var_pos) const;
268 
269  virtual void do_start_subset(unsigned subset_no, const Subset& current_subset);
270  virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops);
271 };
272 
278 struct ConstBaseVisitor : public Visitor
279 {
285  unsigned current_var;
286 
288  ConstBaseVisitor(const Bulletin& bulletin);
289 
291  const Var& get_var();
293  const Var& get_var(unsigned var_pos) const;
294 
295  virtual void do_start_subset(unsigned subset_no, const Subset& current_subset);
296  virtual const Var& do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes& ops);
297 };
298 
299 }
300 }
301 
302 #endif
Bitmap bitmap
Bitmap iteration.
Definition: internals.h:119
virtual void b_variable(Varcode code)
opcode::Visitor methods implementation
Var & get_var()
Get the next variable.
virtual const Var & do_semantic_var(Varinfo info)=0
Request processing, according to info, of a data variabile that is significant for controlling the en...
std::vector< unsigned > refs
Arrays of variable indices corresponding to positions in the bitmap where data is present...
Definition: internals.h:48
virtual void c_increase_scale_ref_width(Varcode code, int change)
opcode::Visitor methods implementation
unsigned current_var
Index of the next variable to be visited.
Definition: internals.h:259
virtual void c_substituted_value_bitmap(Varcode code)
opcode::Visitor methods implementation
BaseVisitor(Bulletin &bulletin)
Create visitor for the given bulletin.
int c_width_change
Current value of width change from C modifier.
Definition: internals.h:125
unsigned next()
Return the next variable offset for which the bitmap reports that data is present.
virtual void r_replication(Varcode code, Varcode delayed_code, const Opcodes &ops)
opcode::Visitor methods implementation
Holds a wreport variable.
Definition: var.h:50
virtual void c_substituted_value(Varcode code)
opcode::Visitor methods implementation
virtual void c_local_descriptor(Varcode code, Varcode desc_code, unsigned nbits)
opcode::Visitor methods implementation
unsigned current_subset_no
Index of the subset being visited.
Definition: internals.h:257
virtual void c_change_data_scale(Varcode code, int change)
opcode::Visitor methods implementation
Common bulletin::Visitor base for visitors that do not modify the bulletin.
Definition: internals.h:278
virtual void do_start_subset(unsigned subset_no, const Subset &current_subset)
Notify the start of a subset.
virtual void do_start_subset(unsigned subset_no, const Subset &current_subset)
Notify the start of a subset.
unsigned current_subset_no
Index of the subset being visited.
Definition: internals.h:283
virtual void do_start_subset(unsigned subset_no, const Subset &current_subset)
Notify the start of a subset.
Associate a Data Present Bitmap to decoded variables in a subset.
Definition: internals.h:39
Bulletin & bulletin
Bulletin being visited.
Definition: internals.h:255
virtual void c_change_data_width(Varcode code, int change)
opcode::Visitor methods implementation
bool eob() const
True if there is no bitmap or if the bitmap has been iterated until the end.
virtual const Var & do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes &ops)
Request processing of a data present bitmap.
Storage for the decoded data of a BUFR or CREX message.
Definition: bulletin.h:63
Holds a variable information table.
Definition: vartable.h:84
virtual void c_char_data(Varcode code)
opcode::Visitor methods implementation
Visitor-style interface for scanning the contents of a data descriptor section.
Definition: opcode.h:167
const Var & get_var()
Get the next variable.
int c_scale_change
Current value of scale change from C modifier.
Definition: internals.h:122
void reset()
Resets the object.
int c04_meaning
Meaning of C04yyy field according to code table B31021.
Definition: internals.h:143
int c_scale_ref_width_increase
Increase of scale, reference value and data width.
Definition: internals.h:134
const Subset * current_subset
Current subset (used to refer to past variables)
Definition: internals.h:116
Common bulletin::Visitor base for visitors that modify the bulletin.
Definition: internals.h:252
virtual void c_modifier(Varcode code)
opcode::Visitor methods implementation
virtual const Var & do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes &ops)
Request processing of a data present bitmap.
Varcode want_bitmap
Nonzero if a Data Present Bitmap is expected.
Definition: internals.h:146
Varinfo get_varinfo(Varcode code)
Return the Varinfo describing the variable code, possibly altered taking into account current C modif...
Sequence of opcodes, as a slice of a Varcode vector.
Definition: opcode.h:50
virtual void c_quality_information_bitmap(Varcode code)
opcode::Visitor methods implementation
const Bulletin & bulletin
Bulletin being visited.
Definition: internals.h:281
short unsigned int Varcode
Holds the WMO variable code of a variable.
Definition: varinfo.h:78
virtual void c_char_data_override(Varcode code, unsigned new_length)
opcode::Visitor methods implementation
std::vector< unsigned >::const_reverse_iterator iter
Iterator over refs.
Definition: internals.h:56
virtual void do_start_repetition(unsigned idx)
Notify the beginning of one instance of an R group.
unsigned data_pos
Number of data items processed so far.
Definition: internals.h:154
virtual void do_char_data(Varcode code)=0
Request processing of C05yyy character data.
Main namespace.
Definition: buffers.h:30
const Var * bitmap
Bitmap being iterated.
Definition: internals.h:42
Implement fast access to information about WMO variables.
Smart pointer to handle/use varinfos.
Definition: varinfo.h:336
virtual const Var & do_bitmap(Varcode code, Varcode rep_code, Varcode delayed_code, const Opcodes &ops)=0
Request processing of a data present bitmap.
void init(const Var &bitmap, const Subset &subset, unsigned anchor)
Initialise the bitmap handler.
ConstBaseVisitor(const Bulletin &bulletin)
Create visitor for the given bulletin.
int c04_bits
Number of extra bits inserted by the current C04yyy modifier (0 for no C04yyy operator in use) ...
Definition: internals.h:140
virtual void do_associated_field(unsigned bit_count, unsigned significance)=0
Request processing of bit_count bits of associated field with the given significance.
int c_string_len_override
Current value of string length override from C08 modifiers (0 for no override)
Definition: internals.h:131
const Vartable * btable
B table used to resolve variable information.
Definition: internals.h:113
virtual void do_attr(Varinfo info, unsigned var_pos, Varcode attr_code)=0
Request processing, according to info, of the attribute attr_code of the variable in position var_pos...
Represent a BUFR/CREX data subset as a list of decoded variables.
Definition: subset.h:40
Implementation of opcode chains, that are used to drive the encoding and decoding process...
virtual void do_var(Varinfo info)=0
Request processing, according to info, of a data variable.
Abstract interface for classes that can be used as targets for the Bulletin Data Descriptor Section i...
Definition: internals.h:110
virtual void c_associated_field(Varcode code, Varcode sig_code, unsigned nbits)
opcode::Visitor methods implementation
unsigned old_anchor
Anchor point of the first bitmap found since the last reset().
Definition: internals.h:69
unsigned current_var
Index of the next variable to be visited.
Definition: internals.h:285