libdballe  9.14
cursor.h
1 #ifndef DBALLE_CURSOR_H
2 #define DBALLE_CURSOR_H
3 
4 #include <dballe/fwd.h>
5 #include <dballe/values.h>
6 #include <memory>
7 #include <vector>
8 #include <wreport/var.h>
9 
10 namespace dballe {
11 
15 class Cursor : public std::enable_shared_from_this<Cursor>
16 {
17 public:
18  virtual ~Cursor();
19 
27  virtual bool has_value() const = 0;
28 
36  virtual int remaining() const = 0;
37 
45  virtual bool next() = 0;
46 
48  virtual void discard() = 0;
49 
53  virtual DBStation get_station() const = 0;
54 };
55 
57 class CursorStation : public Cursor
58 {
59 public:
63  virtual DBValues get_values() const = 0;
64 };
65 
67 class CursorStationData : public Cursor
68 {
69 public:
71  virtual wreport::Varcode get_varcode() const = 0;
72 
74  virtual wreport::Var get_var() const = 0;
75 };
76 
78 class CursorData : public Cursor
79 {
80 public:
82  virtual wreport::Varcode get_varcode() const = 0;
83 
85  virtual wreport::Var get_var() const = 0;
86 
88  virtual Level get_level() const = 0;
89 
91  virtual Trange get_trange() const = 0;
92 
94  virtual Datetime get_datetime() const = 0;
95 };
96 
98 class CursorSummary : public Cursor
99 {
100 public:
102  virtual Level get_level() const = 0;
103 
105  virtual Trange get_trange() const = 0;
106 
108  virtual wreport::Varcode get_varcode() const = 0;
109 
111  virtual DatetimeRange get_datetimerange() const = 0;
112 
114  virtual size_t get_count() const = 0;
115 };
116 
118 class CursorMessage : public Cursor
119 {
120 public:
121  virtual std::shared_ptr<Message> get_message() const = 0;
122 };
123 
124 } // namespace dballe
125 #endif
Base class for cursors that iterate over DB query results.
Definition: cursor.h:15
virtual size_t get_count() const =0
Get the count of elements.
virtual DBValues get_values() const =0
Get the station data values.
virtual wreport::Var get_var() const =0
Get the variable.
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
virtual void discard()=0
Discard the results that have not been read yet.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:688
Cursor iterating over summary entries.
Definition: cursor.h:98
Definition: cmdline.h:18
Cursor iterating over data values.
Definition: cursor.h:78
virtual Trange get_trange() const =0
Get the time range.
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:229
Cursor iterating over messages.
Definition: cursor.h:118
virtual bool next()=0
Get a new item from the results of a query.
Vertical level or layer.
Definition: types.h:624
Range of datetimes.
Definition: types.h:296
virtual DatetimeRange get_datetimerange() const =0
Get the datetime range.
virtual Datetime get_datetime() const =0
Get the datetime.
virtual Level get_level() const =0
Get the level.
virtual DBStation get_station() const =0
Get the whole station data in a single call.
Cursor iterating over station data values.
Definition: cursor.h:67
virtual Level get_level() const =0
Get the level.
Date and time.
Definition: types.h:163
virtual bool has_value() const =0
Check if the cursor points to a valid value.
Cursor iterating over stations.
Definition: cursor.h:57
Definition: types.h:939
virtual Trange get_trange() const =0
Get the time range.
virtual int remaining() const =0
Get the number of rows still to be fetched.
Structures used as input to database insert functions.
virtual wreport::Var get_var() const =0
Get the variable.