LiteCore
Couchbase Lite cross-platform core implementation
Loading...
Searching...
No Matches
c4Observer.h
Go to the documentation of this file.
1//
2// c4Observer.h
3//
4// Copyright 2016-Present Couchbase, Inc.
5//
6// Use of this software is governed by the Business Source License included
7// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
8// in that file, in accordance with the Business Source License, use of this
9// software will be governed by the Apache License, Version 2.0, included in
10// the file licenses/APL2.txt.
11//
12
13#pragma once
14
15#include "c4DocumentTypes.h"
16
19
20
23
26
41typedef void (*C4CollectionObserverCallback)(C4CollectionObserver* observer, void* C4NULLABLE context);
42
43
54 void* C4NULLABLE context,
55 C4Error* C4NULLABLE error) C4API;
56
78 C4CollectionChange outChanges[C4NONNULL],
79 uint32_t maxChanges) C4API;
80
88
90
91
94
100typedef void (*C4DocumentObserverCallback)(C4DocumentObserver* observer, C4Collection* collection, C4String docID,
101 C4SequenceNumber sequence, void* C4NULLABLE context);
102
103
115 void* C4NULLABLE context,
116 C4Error* C4NULLABLE error) C4API;
117
119
120
159
169typedef void (*C4QueryObserverCallback)(C4QueryObserver* observer, C4Query* query, void* C4NULLABLE context);
170
179 void* C4NULLABLE context) C4API;
180
189
204 C4Error* C4NULLABLE error) C4API;
205
207
209
#define NODISCARD
Definition CompilerSupport.h:63
#define CBL_CORE_API
Definition c4Compat.h:131
#define C4NULLABLE
Definition c4Compat.h:38
#define C4API
Definition c4Compat.h:106
#define C4_ASSUME_NONNULL_BEGIN
Definition c4Compat.h:36
#define C4API_END_DECLS
Definition c4Compat.h:108
#define C4NONNULL
Definition c4Compat.h:39
#define C4API_BEGIN_DECLS
Definition c4Compat.h:107
#define C4_ASSUME_NONNULL_END
Definition c4Compat.h:37
C4Slice C4String
Definition c4Base.h:51
struct C4Query C4Query
Opaque handle to a compiled query.
Definition c4Base.h:165
uint64_t C4SequenceNumber
A database sequence number, representing the order in which a revision was created.
Definition c4Base.h:90
struct C4CollectionObserver C4CollectionObserver
A collection-observer reference.
Definition c4Base.h:128
struct C4QueryObserver C4QueryObserver
A query-observer reference.
Definition c4Base.h:171
struct C4DocumentObserver C4DocumentObserver
A document-observer reference.
Definition c4Base.h:141
struct C4Collection C4Collection
Opaque handle to a namespace of documents in an opened database.
Definition c4Base.h:125
NODISCARD CBL_CORE_API C4CollectionObserver * c4dbobs_createOnCollection(C4Collection *collection, C4CollectionObserverCallback callback, void *context, C4Error *error)
Creates a new collection observer, with a callback that will be invoked after one or more documents i...
NODISCARD CBL_CORE_API C4QueryObserver * c4queryobs_create(C4Query *query, C4QueryObserverCallback callback, void *context)
Creates a new query observer, with a callback that will be invoked when the query results change,...
NODISCARD CBL_CORE_API C4DocumentObserver * c4docobs_createWithCollection(C4Collection *collection, C4String docID, C4DocumentObserverCallback callback, void *context, C4Error *error)
Creates a new document observer, with a callback that will be invoked when the document changes.
void(* C4CollectionObserverCallback)(C4CollectionObserver *observer, void *context)
Callback invoked by a collection/database observer.
Definition c4Observer.h:41
NODISCARD CBL_CORE_API C4CollectionObservation c4dbobs_getChanges(C4CollectionObserver *observer, C4CollectionChange outChanges[], uint32_t maxChanges)
Identifies which documents have changed in the collection since the last time this function was calle...
void(* C4DocumentObserverCallback)(C4DocumentObserver *observer, C4Collection *collection, C4String docID, C4SequenceNumber sequence, void *context)
Callback invoked by a document observer.
Definition c4Observer.h:100
CBL_CORE_API void c4queryobs_setEnabled(C4QueryObserver *obs, bool enabled)
Enables a query observer so its callback can be called, or disables it to stop callbacks.
NODISCARD CBL_CORE_API C4QueryEnumerator * c4queryobs_getEnumerator(C4QueryObserver *obs, bool forget, C4Error *error)
Returns the current query results, if any.
void(* C4QueryObserverCallback)(C4QueryObserver *observer, C4Query *query, void *context)
Callback invoked by a query observer, notifying that the query results have changed.
Definition c4Observer.h:169
CBL_CORE_API void c4dbobs_releaseChanges(C4CollectionChange changes[], uint32_t numChanges)
Releases the memory used by the C4CollectionChange structs (to hold the docID and revID strings....
Represents a change to a document in a collection, as returned from c4dbobs_getChanges.
Definition c4DocumentTypes.h:119
A struct to hold the results of a call to c4dbobs_getChanges.
Definition c4DocumentTypes.h:134
An error value.
Definition c4Error.h:133
A query result enumerator.
Definition c4QueryTypes.h:54