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