libwreport  3.40
bitmaps.h
1 #ifndef WREPORT_BULLETIN_BITMAPS_H
2 #define WREPORT_BULLETIN_BITMAPS_H
3 
4 #include <vector>
5 #include <wreport/var.h>
6 
7 namespace wreport {
8 struct Var;
9 struct Subset;
10 
11 namespace bulletin {
12 
14 struct Bitmap
15 {
18 
23  std::vector<unsigned> refs;
24 
31  std::vector<unsigned>::const_reverse_iterator iter;
32 
44  Bitmap(const Var& bitmap, const Subset& subset, unsigned anchor);
45  Bitmap(const Var& bitmap, const Subset& subset);
46  Bitmap(const Bitmap&) = delete;
47  ~Bitmap();
48  Bitmap& operator=(const Bitmap&) = delete;
49 
54  bool eob() const;
55 
60  unsigned next();
61 
63  void reuse();
64 };
65 
66 struct Bitmaps
67 {
70 
72  Bitmap* current = nullptr;
73 
75  Bitmap* last = nullptr;
76 
77  Bitmaps() {}
78  Bitmaps(const Bitmaps&) = delete;
79  ~Bitmaps();
80  Bitmaps& operator=(const Bitmaps&) = delete;
81 
82  void define(const Var& bitmap, const Subset& subset);
83  void define(const Var& bitmap, const Subset& subset, unsigned anchor_point);
84 
85  void reuse_last();
86 
87  void discard_last();
88 
93  unsigned next();
94 
96  bool active() const { return (bool)current; }
97 };
98 
99 } // namespace bulletin
100 } // namespace wreport
101 #endif
Definition: bitmaps.h:66
std::vector< unsigned > refs
Arrays of variable indices corresponding to positions in the bitmap where data is present...
Definition: bitmaps.h:23
unsigned next()
Return the next variable offset for which the bitmap reports that data is present.
void reuse()
Reset the bitmap iterator, to reuse the bitmap another time.
A physical variable.
Definition: var.h:24
bool active() const
Return true if there is an active bitmap.
Definition: bitmaps.h:96
Associate a Data Present Bitmap to decoded variables in a subset.
Definition: bitmaps.h:14
uint16_t Varcode
Holds the WMO variable code of a variable.
Definition: fwd.h:12
Bitmap * current
Currently active bitmap.
Definition: bitmaps.h:72
unsigned next()
Return the next variable offset for which the bitmap reports that data is present.
std::vector< unsigned >::const_reverse_iterator iter
Iterator over refs.
Definition: bitmaps.h:31
String functions.
Definition: benchmark.h:13
Bitmap * last
Last bitmap used.
Definition: bitmaps.h:75
bool eob() const
True if there is no bitmap or if the bitmap has been iterated until the end.
Varcode pending_definitions
Nonzero if a Data Present Bitmap is expected.
Definition: bitmaps.h:69
Represent a BUFR/CREX data subset as a list of decoded variables.
Definition: subset.h:12
Var bitmap
Bitmap being iterated.
Definition: bitmaps.h:17
Bitmap(const Var &bitmap, const Subset &subset, unsigned anchor)
Create a new bitmap.