Ditto 1.1.7
PendingCollectionsOperation.hpp
1#ifndef _DITTO_PENDING_COLLECTIONS_OPERATION_
2#define _DITTO_PENDING_COLLECTIONS_OPERATION_
3
4#include "Collection.hpp"
5#include "CollectionsEvent.hpp"
6#include "LiveQuery.hpp"
7#include "PendingCursorOperation.hpp"
8#include "SortDirection.hpp"
9#include "Subscription.hpp"
10
11#include <functional>
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace ditto {
17class DittoHandleWrapper;
18
20 std::function<void(CollectionsEvent)> fn;
21};
22
24 std::function<void(CollectionsEvent, std::function<void()> &)> fn;
25};
26
30typedef std::function<void(CollectionsEvent)> CollectionsEventCallback;
31
35typedef std::function<void(CollectionsEvent, std::function<void()> &)>
36 CollectionsEventWithNextSignalCallback;
37
65 friend class Store;
66
67 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
68 PendingCursorOperation pending_cursor_operation;
69
71 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper);
72
73public:
75
84
99
110 PendingCollectionsOperation &sort(std::string query, SortDirection direction);
111
118 std::vector<Collection> exec() const;
119
131 Subscription subscribe() const;
132
146 std::shared_ptr<LiveQuery>
147 observe(CollectionsEventHandler handler) const DITTO_DEPRECATED;
148
162 std::shared_ptr<LiveQuery>
163 observe(CollectionsEventCallback event_callback) const;
164
177 std::shared_ptr<LiveQuery>
178 observe_local(CollectionsEventHandler handler) const DITTO_DEPRECATED;
179
192 std::shared_ptr<LiveQuery>
193 observe_local(CollectionsEventCallback event_callback) const;
194
209 std::shared_ptr<LiveQuery> observe_with_next_signal(
210 CollectionsEventWithNextSignalHandler handler) const DITTO_DEPRECATED;
211
226 std::shared_ptr<LiveQuery> observe_with_next_signal(
227 CollectionsEventWithNextSignalCallback event_callback) const;
228
242 std::shared_ptr<LiveQuery> observe_local_with_next_signal(
243 CollectionsEventWithNextSignalHandler handler) const DITTO_DEPRECATED;
244
258 std::shared_ptr<LiveQuery> observe_local_with_next_signal(
259 CollectionsEventWithNextSignalCallback event_callback) const;
260
261private:
269 static LiveQueryEventCallback
270 buildLiveQueryCallback(CollectionsEventCallback callback,
271 std::shared_ptr<DittoHandleWrapper> dhw);
272
280 static LiveQueryEventWithNextSignalCallback
281 buildLiveQueryWithNextSignalCallback(
282 CollectionsEventWithNextSignalCallback callback,
283 std::shared_ptr<DittoHandleWrapper> dhw);
284};
285} // namespace ditto
286#endif
Provides information about the changes that have occurred in relation to an event delivered when obse...
Definition: CollectionsEvent.hpp:21
These objects are returned when calling collections() on Store objects.
Definition: PendingCollectionsOperation.hpp:64
PendingCollectionsOperation & sort(std::string query, SortDirection direction)
Sort the collections based on a property of the collection.
Definition: PendingCollectionsOperation.cpp:89
std::vector< Collection > exec() const
Return the list of collections requested based on the preceding function chaining.
Definition: PendingCollectionsOperation.cpp:19
PendingCollectionsOperation & offset(uint32_t offset)
Offset the resulting set of collections.
Definition: PendingCollectionsOperation.cpp:77
PendingCollectionsOperation & limit(uint32_t limit)
Limit the number of collections that get returned.
Definition: PendingCollectionsOperation.cpp:83
std::shared_ptr< LiveQuery > observe_local(CollectionsEventHandler handler) const DITTO_DEPRECATED
Enables you to listen for changes that occur in relation to the collections that are known about loca...
Definition: PendingCollectionsOperation.cpp:36
Subscription subscribe() const
Subscribes the device to updates about collections that other devices know about.
Definition: PendingCollectionsOperation.cpp:95
std::shared_ptr< LiveQuery > observe_local_with_next_signal(CollectionsEventWithNextSignalHandler handler) const DITTO_DEPRECATED
Enables you to listen for changes that occur in relation to the collections that are known about loca...
Definition: PendingCollectionsOperation.cpp:63
std::shared_ptr< LiveQuery > observe_with_next_signal(CollectionsEventWithNextSignalHandler handler) const DITTO_DEPRECATED
Enables you to listen for changes that occur in relation to the collections that are known about....
Definition: PendingCollectionsOperation.cpp:49
std::shared_ptr< LiveQuery > observe(CollectionsEventHandler handler) const DITTO_DEPRECATED
Enables you to listen for changes that occur in relation to the collections that are known about....
Definition: PendingCollectionsOperation.cpp:25
These objects are returned when using find-like functionality on Collection objects.
Definition: PendingCursorOperation.hpp:49
Provides access to Collections and a write transaction API.
Definition: Store.hpp:20
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition: Subscription.hpp:17
Definition: PendingCollectionsOperation.hpp:19
Definition: PendingCollectionsOperation.hpp:23