libdballe 9.6
core/cursor.h
1#ifndef DBALLE_CORE_CURSOR_H
2#define DBALLE_CORE_CURSOR_H
3
4#include <dballe/cursor.h>
5#include <dballe/core/enq.h>
6#include <memory>
7
8namespace dballe {
9namespace impl {
10
13{
14 virtual void enq(Enq& enq) const = 0;
15
17 inline static std::shared_ptr<CursorStation> downcast(std::shared_ptr<dballe::CursorStation> c)
18 {
19 auto res = std::dynamic_pointer_cast<CursorStation>(c);
20 if (!res)
21 throw std::runtime_error("Attempted to downcast the wrong kind of cursor");
22 return res;
23 }
24
26 static std::shared_ptr<CursorStation> make_empty();
27};
28
31{
32 virtual void enq(Enq& enq) const = 0;
33
35 inline static std::shared_ptr<CursorStationData> downcast(std::shared_ptr<dballe::CursorStationData> c)
36 {
37 auto res = std::dynamic_pointer_cast<CursorStationData>(c);
38 if (!res)
39 throw std::runtime_error("Attempted to downcast the wrong kind of cursor");
40 return res;
41 }
42
44 static std::shared_ptr<CursorStationData> make_empty();
45};
46
49{
50 virtual void enq(Enq& enq) const = 0;
51
53 inline static std::shared_ptr<CursorData> downcast(std::shared_ptr<dballe::CursorData> c)
54 {
55 auto res = std::dynamic_pointer_cast<CursorData>(c);
56 if (!res)
57 throw std::runtime_error("Attempted to downcast the wrong kind of cursor");
58 return res;
59 }
60
62 static std::shared_ptr<CursorData> make_empty();
63};
64
67{
68 virtual void enq(Enq& enq) const = 0;
69
71 inline static std::shared_ptr<CursorSummary> downcast(std::shared_ptr<dballe::CursorSummary> c)
72 {
73 auto res = std::dynamic_pointer_cast<CursorSummary>(c);
74 if (!res)
75 throw std::runtime_error("Attempted to downcast the wrong kind of cursor");
76 return res;
77 }
78
80 static std::shared_ptr<CursorSummary> make_empty();
81};
82
85{
86 virtual void enq(Enq& enq) const {}
87
89 inline static std::shared_ptr<CursorMessage> downcast(std::shared_ptr<dballe::CursorMessage> c)
90 {
91 auto res = std::dynamic_pointer_cast<CursorMessage>(c);
92 if (!res)
93 throw std::runtime_error("Attempted to downcast the wrong kind of cursor");
94 return res;
95 }
96
98 static std::shared_ptr<CursorMessage> make_empty();
99};
100
101}
102}
103#endif
Cursor iterating over data values.
Definition: cursor.h:78
Cursor iterating over messages.
Definition: cursor.h:118
Cursor iterating over station data values.
Definition: cursor.h:67
Cursor iterating over stations.
Definition: cursor.h:57
Cursor iterating over summary entries.
Definition: cursor.h:98
Cursor iterating over data values.
Definition: core/cursor.h:49
static std::shared_ptr< CursorData > make_empty()
Create a CursorData iterating on no results.
static std::shared_ptr< CursorData > downcast(std::shared_ptr< dballe::CursorData > c)
Downcast a shared_ptr pointer.
Definition: core/cursor.h:53
Cursor iterating over messages.
Definition: core/cursor.h:85
static std::shared_ptr< CursorMessage > downcast(std::shared_ptr< dballe::CursorMessage > c)
Downcast a shared_ptr pointer.
Definition: core/cursor.h:89
static std::shared_ptr< CursorMessage > make_empty()
Create a CursorStation iterating on no results.
Cursor iterating over station data values.
Definition: core/cursor.h:31
static std::shared_ptr< CursorStationData > downcast(std::shared_ptr< dballe::CursorStationData > c)
Downcast a shared_ptr pointer.
Definition: core/cursor.h:35
static std::shared_ptr< CursorStationData > make_empty()
Create a CursorStationData iterating on no results.
Cursor iterating over stations.
Definition: core/cursor.h:13
static std::shared_ptr< CursorStation > downcast(std::shared_ptr< dballe::CursorStation > c)
Downcast a shared_ptr pointer.
Definition: core/cursor.h:17
static std::shared_ptr< CursorStation > make_empty()
Create a CursorStation iterating on no results.
Cursor iterating over summary entries.
Definition: core/cursor.h:67
static std::shared_ptr< CursorSummary > downcast(std::shared_ptr< dballe::CursorSummary > c)
Downcast a shared_ptr pointer.
Definition: core/cursor.h:71
static std::shared_ptr< CursorSummary > make_empty()
Create a CursorSummary iterating on no results.
Class passed to key-value accessors to set values in an invoker-defined way.
Definition: core/enq.h:18