Ditto 4.13.1
 
Loading...
Searching...
No Matches
LiveQuery.hpp
1#ifndef DITTO_LIVE_QUERY_H
2#define DITTO_LIVE_QUERY_H
3
4#include "Document.hpp"
5#include "Helpers.hpp"
6#include "LiveQueryEvent.hpp"
7#include "LiveQueryMove.hpp"
8#include "Observer.hpp"
9#include "SingleDocumentLiveQueryEvent.hpp"
10#include "Subscription.hpp"
11#include "json.hpp"
12
13#include <functional>
14#include <memory>
15#include <string>
16#include <vector>
17
18namespace ditto {
19class DittoHandleWrapper;
20class OrderBy;
21
22DITTO_DISABLE_DEPRECATED_WARNINGS(
23 "Document is deprecated, and will be removed in v5")
24
25
32using SingleDocumentLiveQueryEventCallback DITTO_DEPRECATED_BECAUSE(
33 "Use DQL (Ditto Query Language) instead. For more information "
34 "see: https://ditto.com/link/legacy-to-dql-guide") =
35 std::function<void(std::shared_ptr<Document>,
37
43 * updates relating to a live query associated with a single document.
44 */
45struct DITTO_DEPRECATED_BECAUSE(
46 "Use DQL (Ditto Query Language) instead. For more information "
47 "see: https://ditto.com/link/legacy-to-dql-guide")
49 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent)>
50 fn;
51};
52
62 DITTO_DEPRECATED_BECAUSE(
63 "Use Ditto's query language with "
64 "Store::execute(). For more information "
65 "see: https://ditto.com/link/legacy-to-dql-guide") =
66 std::function<void(std::shared_ptr<Document>,
68 std::function<void()> &)>;
69
72 * information see: https://ditto.com/link/legacy-to-dql-guide
73 *
74 * @brief A thin wrapper around a function that will get called when there are
75 * updates relating to a live query associated with a single document that has
76 * an associated function to call when the next event is ready to be delivered.
77 */
78struct DITTO_DEPRECATED_BECAUSE(
79 "Use DQL (Ditto Query Language) instead. For more information "
80 "see: https://ditto.com/link/legacy-to-dql-guide")
82 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent,
83 std::function<void()> &)>
84 fn;
85};
86
94using LiveQueryEventCallback DITTO_DEPRECATED_BECAUSE(
95 "Use DQL (Ditto Query Language) instead. For more information "
96 "see: https://ditto.com/link/legacy-to-dql-guide") =
97 std::function<void(std::vector<Document>, LiveQueryEvent)>;
103
106struct DITTO_DEPRECATED_BECAUSE(
107 "Use DQL (Ditto Query Language) instead. For more information "
108 "see: https://ditto.com/link/legacy-to-dql-guide") LiveQueryEventHandler {
109 std::function<void(std::vector<Document>, LiveQueryEvent)> fn;
110};
111
120using LiveQueryEventWithNextSignalCallback DITTO_DEPRECATED_BECAUSE(
121 "Use DQL (Ditto Query Language) instead. For more information "
122 "see: https://ditto.com/link/legacy-to-dql-guide") =
123 std::function<void(std::vector<Document>, LiveQueryEvent,
124 std::function<void()> &)>;
125
132
134struct DITTO_DEPRECATED_BECAUSE(
135 "Use DQL (Ditto Query Language) instead. For more information "
136 "see: https://ditto.com/link/legacy-to-dql-guide")
138 std::function<void(std::vector<Document>, LiveQueryEvent,
139 std::function<void()> &)>
140 fn;
141};
142
143DITTO_REENABLE_WARNINGS
144
146 * @deprecated Use DQL (%Ditto Query Language) instead. For more
147 * information see: https://ditto.com/link/legacy-to-dql-guide
148 *
149 * @brief The type that is returned when calling `observe_local`. It handles the
150 * logic for calling the event handler that is provided to the `observe_local`
151 * call.
152 *
153 * These objects must be kept in scope for as long as you wish to keep receiving
154 * updates about the associated query.
155 */
156class DITTO_DEPRECATED_BECAUSE(
157 "Use DQL (Ditto Query Language) instead. For more information "
158 "see: https://ditto.com/link/legacy-to-dql-guide") LiveQuery
159 : public Observer {
160 DITTO_DISABLE_DEPRECATED_WARNINGS("The legacy query API is deprecated")
161
162public:
163 ~LiveQuery(); // required by pimpl.
164 LiveQuery(LiveQuery &&);
165 LiveQuery &operator=(LiveQuery &&);
166
167 struct ArcCtx;
168
169private:
170 LiveQuery(std::shared_ptr<DittoHandleWrapper> const &ditto_handle_wrapper,
171 std::string query, nlohmann::json query_args, std::string coll_name,
172 std::shared_ptr<OrderBy> const &order_by, int32_t limit,
173 uint32_t offset, LiveQueryAvailability_t availability,
174 std::unique_ptr<Subscription> &&subscription,
175 LiveQueryEventWithNextSignalCallback &&event_callback);
176
177 void on_stop() override;
178 // Non-trivial dtor requires manual swap for assignment operators.
179 static void swap(LiveQuery &lhs, LiveQuery &rhs) noexcept;
180
181 std::unique_ptr<ArcCtx> ctx; // pimpl.
182
183 friend class PendingCursorOperation;
184 friend class PendingIDSpecificOperation;
185
186 DITTO_REENABLE_WARNINGS
187};
188
189} // namespace ditto
190
191#endif
A document belonging to a Collection with an inner value and an identifier (DocumentId).
Definition Document.hpp:22
The events that you receive when dealing with live queries.
Definition LiveQueryEvent.hpp:20
Observer()
Constructs a new Observer.
Definition order_by.hpp:19
Provides information about a live query event relating to a single document live query.
Definition SingleDocumentLiveQueryEvent.hpp:21
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
std::function< void(std::shared_ptr< Document >, SingleDocumentLiveQueryEvent)> SingleDocumentLiveQueryEventCallback
A function that will get called when there are updates relating to a live query associated with a sin...
Definition LiveQuery.hpp:32
std::function< void(std::vector< Document >, LiveQueryEvent)> LiveQueryEventCallback
A function that will get called when there are updates relating to a live query.
Definition LiveQuery.hpp:88
std::function< void(std::shared_ptr< Document >, SingleDocumentLiveQueryEvent, std::function< void()> &)> SingleDocumentLiveQueryEventWithNextSignalCallback
A function that will get called when there are updates relating to a live query associated with a sin...
Definition LiveQuery.hpp:59
std::function< void(std::vector< Document >, LiveQueryEvent, std::function< void()> &)> LiveQueryEventWithNextSignalCallback
A function that will get called when there are updates relating to a live query that has an associate...
Definition LiveQuery.hpp:112
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:100
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:127
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:46
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:75