Ditto 4.5.2
Loading...
Searching...
No Matches
LiveQuery.hpp
1#ifndef _DITTO_LIVE_QUERY_
2#define _DITTO_LIVE_QUERY_
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
26typedef std::function<void(std::shared_ptr<Document>,
27 SingleDocumentLiveQueryEvent)>
28 SingleDocumentLiveQueryEventCallback;
29
35 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent)>
36 fn;
37};
38
44typedef std::function<void(std::shared_ptr<Document>,
46 std::function<void()> &)>
47 SingleDocumentLiveQueryEventWithNextSignalCallback;
48
55 std::function<void(std::shared_ptr<Document>, SingleDocumentLiveQueryEvent,
56 std::function<void()> &)>
57 fn;
58};
59
64typedef std::function<void(std::vector<Document>, LiveQueryEvent)>
65 LiveQueryEventCallback;
66
72 std::function<void(std::vector<Document>, LiveQueryEvent)> fn;
73};
74
80typedef std::function<void(std::vector<Document>, LiveQueryEvent,
81 std::function<void()> &)>
82 LiveQueryEventWithNextSignalCallback;
83
90 std::function<void(std::vector<Document>, LiveQueryEvent,
91 std::function<void()> &)>
92 fn;
93};
94
103class LiveQuery : public Observer {
104 friend class PendingCursorOperation;
105 friend class PendingIDSpecificOperation;
106
107public:
108 ~LiveQuery();
109
110private:
111 void on_stop() override;
112 LiveQuery(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
113 std::string query, nlohmann::json query_args, std::string coll_name,
114 std::shared_ptr<OrderBy> &order_by, int32_t limit, uint32_t offset,
115 LiveQueryAvailability_t availability, Subscription *subscription,
116 LiveQueryEventWithNextSignalCallback event_callback);
117
118 class LiveQueryCtx;
119 LiveQueryCtx *ctx;
120 bool stopped;
121};
122
123} // namespace ditto
124
125#endif
The events that you receive when dealing with live queries.
Definition LiveQueryEvent.hpp:15
The type that is returned when calling observe_local. It handles the logic for calling the event hand...
Definition LiveQuery.hpp:103
An observation token returned by any observation API in the Ditto SDK. Retain this object to continue...
Definition Observer.hpp:11
These objects are returned when using find-like functionality on Collection objects.
Definition PendingCursorOperation.hpp:44
These objects are returned when using Collection::find_by_id functionality.
Definition PendingIDSpecificOperation.hpp:40
Provides information about a live query event relating to a single document live query.
Definition SingleDocumentLiveQueryEvent.hpp:16
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition Subscription.hpp:19
basic_json<> json
default JSON class
Definition json.hpp:2933
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:71
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:89
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:34
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:54