Ditto  3.0.4
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 
16 namespace ditto {
17 class DittoHandleWrapper;
18 
20  std::function<void(CollectionsEvent)> fn;
21 };
22 
24  std::function<void(CollectionsEvent, std::function<void()> &)> fn;
25 };
26 
30 typedef std::function<void(CollectionsEvent)> CollectionsEventCallback;
31 
35 typedef std::function<void(CollectionsEvent, std::function<void()> &)>
36  CollectionsEventWithNextSignalCallback;
37 
59  friend class Store;
60 
61  std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
62  PendingCursorOperation pending_cursor_operation;
63 
65  std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper);
66 
67 public:
69 
78 
93 
104  PendingCollectionsOperation &sort(std::string query, SortDirection direction);
105 
112  std::vector<Collection> exec() const;
113 
125  std::shared_ptr<Subscription> subscribe() const;
126 
139  std::shared_ptr<LiveQuery>
140  observe_local(CollectionsEventCallback event_callback) const;
141 
155  std::shared_ptr<LiveQuery> observe_local_with_next_signal(
156  CollectionsEventWithNextSignalCallback event_callback) const;
157 
158 private:
166  static LiveQueryEventCallback
167  buildLiveQueryCallback(CollectionsEventCallback callback,
168  std::shared_ptr<DittoHandleWrapper> dhw);
169 
177  static LiveQueryEventWithNextSignalCallback
178  buildLiveQueryWithNextSignalCallback(
179  CollectionsEventWithNextSignalCallback callback,
180  std::shared_ptr<DittoHandleWrapper> dhw);
181 };
182 } // namespace ditto
183 #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:58
PendingCollectionsOperation & sort(std::string query, SortDirection direction)
Sort the collections based on a property of the collection.
Definition: PendingCollectionsOperation.cpp:52
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:40
PendingCollectionsOperation & limit(uint32_t limit)
Limit the number of collections that get returned.
Definition: PendingCollectionsOperation.cpp:46
std::shared_ptr< LiveQuery > observe_local(CollectionsEventCallback event_callback) const
Enables you to listen for changes that occur in relation to the collections that are known about loca...
Definition: PendingCollectionsOperation.cpp:24
std::shared_ptr< Subscription > subscribe() const
Subscribes the device to updates about collections that other devices know about.
Definition: PendingCollectionsOperation.cpp:58
std::shared_ptr< LiveQuery > observe_local_with_next_signal(CollectionsEventWithNextSignalCallback event_callback) const
Enables you to listen for changes that occur in relation to the collections that are known about loca...
Definition: PendingCollectionsOperation.cpp:32
These objects are returned when using find-like functionality on Collection objects.
Definition: PendingCursorOperation.hpp:44
Provides access to Collections and a write transaction API.
Definition: Store.hpp:21
Definition: PendingCollectionsOperation.hpp:19
Definition: PendingCollectionsOperation.hpp:23