|
Couchbase Lite C++
Couchbase Lite C++ API
|
A replicator that syncs documents between a local database's collections and a target database. More...
#include <cbl++/Replicator.hh>
Public Types | |
| using | ChangeListener = cbl::ListenerToken<Replicator, const CBLReplicatorStatus&> |
| A change listener that notifies you when the replicator's status changes. | |
| using | DocumentReplicationListener |
| A document replication listener that notifies you when documents are replicated. | |
Public Member Functions | |
| Replicator (const ReplicatorConfiguration &config) | |
| Creates a new replicator using the specified config. | |
| void | start (bool resetCheckpoint=false) |
| Starts a replicator, asynchronously. | |
| void | stop () |
| Stops a running replicator, asynchronously. | |
| void | setHostReachable (bool r) |
| Informs the replicator whether it's considered possible to reach the remote host with the current network configuration. | |
| void | setSuspended (bool s) |
| Puts the replicator in or out of "suspended" state. | |
| CBLReplicatorStatus | status () const |
| Returns the replicator's current status. | |
| std::string | correlationID () const |
| Returns the ID used to correlate the replication session with the remote endpoint. | |
| fleece::Dict | pendingDocumentIDs (Collection &collection) const |
| Indicates which documents in the given collection have local changes that have not yet been pushed to the server by this replicator. | |
| bool | isDocumentPending (std::string_view docID, Collection &collection) const |
| Indicates whether the document with the given ID in the given collection has local changes that have not yet been pushed to the server by this replicator. | |
| ChangeListener | addChangeListener (ChangeListener::Callback callback) |
| Registers a listener that will be called when the replicator's status changes. | |
| DocumentReplicationListener | addDocumentReplicationListener (DocumentReplicationListener::Callback callback) |
| Registers a listener that will be called when documents are replicated. | |
| Replicator () noexcept | |
| Constructs a null reference (one that points to no object). | |
| Replicator & | operator= (std::nullptr_t) |
| Releases the underlying object and resets this to a null reference. | |
| bool | valid () const |
| Returns true if this references an object, or false if it is a null reference. | |
| operator bool () const | |
| Returns true if this references an object (same as valid). | |
| bool | operator== (const Replicator &other) const |
| Returns true if both sides reference the same object, or are both null references. | |
| bool | operator!= (const Replicator &other) const |
| Returns true if the two sides reference different objects. | |
| CBLReplicator *_Nullable | ref () const |
| Returns a pointer to the underlying C object (CBLReplicator), or NULL if this is a null reference. | |
| Replicator (const Replicator &other) noexcept | |
| Copy constructor. | |
| Replicator (Replicator &&other) noexcept | |
| Move constructor. | |
| Replicator & | operator= (const Replicator &other) noexcept |
| Copy assignment. | |
| Replicator & | operator= (Replicator &&other) noexcept |
| Move assignment. | |
| void | clear () |
| Releases the underlying C CBLReplicator and drops the C++ collection-configuration map. | |
Protected Member Functions | |
| Replicator (CBLReplicator *_Nullable ref) | |
| (Internal) Constructs a reference wrapping, and retaining, a C object pointer. | |
A replicator that syncs documents between a local database's collections and a target database.
| using cbl::Replicator::ChangeListener = cbl::ListenerToken<Replicator, const CBLReplicatorStatus&> |
A change listener that notifies you when the replicator's status changes.
A document replication listener that notifies you when documents are replicated.
|
inline |
Creates a new replicator using the specified config.
|
inlinenoexcept |
Constructs a null reference (one that points to no object).
|
inlineexplicitprotected |
(Internal) Constructs a reference wrapping, and retaining, a C object pointer.
|
inlinenoexcept |
Copy constructor.
Both *this and other refer to the same underlying CBLReplicator handle (its refcount is incremented) and share the collection-configuration map.
|
inlinenoexcept |
Move constructor.
Takes over other's CBLReplicator handle and collection-configuration map, leaving other empty.
|
inlinenodiscard |
Registers a listener that will be called when the replicator's status changes.
| callback | The callback to be invoked. |
|
inlinenodiscard |
Registers a listener that will be called when documents are replicated.
| callback | The callback to be invoked. |
|
inline |
Releases the underlying C CBLReplicator and drops the C++ collection-configuration map.
After this call the object is empty (its Replicator::operator bool() const returns false).
|
inline |
Returns the ID used to correlate the replication session with the remote endpoint.
This value is intended for logging and diagnostics, and is an empty string until the replicator receives a correlation ID from the remote endpoint.
|
inline |
Indicates whether the document with the given ID in the given collection has local changes that have not yet been pushed to the server by this replicator.
This is equivalent to, but faster than, calling Replicator::pendingDocumentIDs and checking whether the result contains docID. See that function's documentation for details.
|
inlineexplicit |
Returns true if this references an object (same as valid).
|
inline |
Returns true if the two sides reference different objects.
|
inlinenoexcept |
Copy assignment.
Releases the currently-referenced handle (if any), then makes *this refer to the same CBLReplicator as other (refcount incremented) and share its collection-configuration map.
|
inlinenoexcept |
Move assignment.
Releases the currently-referenced handle (if any), then takes over other's CBLReplicator handle and collection-configuration map; other is left empty.
|
inline |
Releases the underlying object and resets this to a null reference.
|
inline |
Returns true if both sides reference the same object, or are both null references.
|
inline |
Indicates which documents in the given collection have local changes that have not yet been pushed to the server by this replicator.
This is of course a snapshot, that will go out of date as the replicator makes progress and/or documents are saved locally.
The result is, effectively, a set of document IDs: a dictionary whose keys are the IDs and values are true. If there are no pending documents, the dictionary is empty.
|
inline |
Returns a pointer to the underlying C object (CBLReplicator), or NULL if this is a null reference.
|
inline |
Informs the replicator whether it's considered possible to reach the remote host with the current network configuration.
The default value is true. This only affects the replicator's behavior while it's in the Offline state: Setting it to false will cancel any pending retry and prevent future automatic retries. Setting it back to true will initiate an immediate retry.
|
inline |
Puts the replicator in or out of "suspended" state.
The default is false. Setting suspended=true causes the replicator to disconnect and enter Offline state; it will not attempt to reconnect while it's suspended. Setting suspended=false causes the replicator to attempt to reconnect, if it was connected when suspended, and is still in Offline state.
|
inline |
Starts a replicator, asynchronously.
Does nothing if it's already started.
| resetCheckpoint | If true, the persistent saved state ("checkpoint") for this replication will be discarded, causing it to re-scan all documents. This significantly increases time and bandwidth (redundant docs are not transferred, but their IDs are) but can resolve unexpected problems with missing documents if one side or the other has gotten out of sync. |
|
inline |
Returns the replicator's current status.
|
inline |
Stops a running replicator, asynchronously.
Does nothing if it's not already started. The replicator will call your replicator change listener if registered with an activity level of kCBLReplicatorStopped after it stops. Until then, consider it still active.
|
inline |
Returns true if this references an object, or false if it is a null reference.