libwreport  3.6
bitmaps.h
1 #ifndef WREPORT_BULLETIN_BITMAPS_H
2 #define WREPORT_BULLETIN_BITMAPS_H
3 
4 #include <wreport/var.h>
5 #include <vector>
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 Bitmap&) = delete;
46  ~Bitmap();
47  Bitmap& operator=(const Bitmap&) = delete;
48 
53  bool eob() const;
54 
59  unsigned next();
60 
62  void reuse();
63 };
64 
65 struct Bitmaps
66 {
68  Varcode pending_definitions = 0;
69 
71  Bitmap* current = nullptr;
72 
74  Bitmap* last = nullptr;
75 
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, unsigned anchor_point);
83 
84  void reuse_last();
85 
86  void discard_last();
87 
92  unsigned next();
93 
95  bool active() const { return (bool)current; }
96 };
97 
98 }
99 }
100 #endif
Definition: bitmaps.h:65
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:23
bool active() const
Return true if there is an active bitmap.
Definition: bitmaps.h:95
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: varinfo.h:57
std::vector< unsigned >::const_reverse_iterator iter
Iterator over refs.
Definition: bitmaps.h:31
String functions.
Definition: benchmark.h:13
bool eob() const
True if there is no bitmap or if the bitmap has been iterated until the end.
Represent a BUFR/CREX data subset as a list of decoded variables.
Definition: subset.h:13
Var bitmap
Bitmap being iterated.
Definition: bitmaps.h:17
Bitmap(const Var &bitmap, const Subset &subset, unsigned anchor)
Create a new bitmap.