QtDataSync
4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
|
A generic variant of the ConflictResolver to handel dataobjects instead of json data. More...
#include <conflictresolver.h>
Public Member Functions | |
GenericConflictResolver (QObject *parent=nullptr) | |
Default constructor. | |
QJsonObject | resolveConflict (int typeId, const QJsonObject &data1, const QJsonObject &data2) const override |
The method called to resolve conflicts between two datasets. More... | |
Protected Member Functions | |
virtual T1 | resolveConflict (T1 data1, T1 data2, QObject *parent) const =0 |
A generic variant of the ConflictResolver to handel dataobjects instead of json data.
Args | The types this resolver should be able resolve conflicts for |
The class is basically a wrapper around the ConflictResolver that deserializes all incoming data and that passes the objects to a generic resolveConflict() method. The result is then serialized again and returned. In order to handle a type it must be passed as a template parameter. The resulting generic class will have one pure virtual method for any passed type you need to reimplement. In order to handle types that have not been captured that way you can reimplement the resolveUnknownConflict() method.
Definition at line 50 of file conflictresolver.h.
|
inlineoverride |
The method called to resolve conflicts between two datasets.
typeId | The id of the type of which the two conflicted objects are |
data1 | The first dataset |
data2 | The second dataset |
QException | In case data corruption was detected an exception can be thrown to abort the synchronization. This will put the engine in an (unrecoverable) error state. |
Must be implemented as the main method of the resolver. The method must always return something. If you find that you cannot decide how to merge, simply return a default constructed json object. In that case, the library will ignore the result and proceed to merge as if no conflict resolver was present.
Definition at line 59 of file conflictresolver.h.
|
protectedpure virtual |
The method called to resolve conflicts between two datasets.
data1 | The first dataset |
data2 | The second dataset |
parent | A temporary qobject to use as parent for created QObjects |
NoConflictResultException | Thrown if resolving was not possible and the default JSON-based resolving should be used instead |
QException | In case data corruption was detected an exception can be thrown to abort the synchronization. This will put the engine in an (unrecoverable) error state. |
Must be implemented as the main method of the resolver. The method must always return something. If you find that you cannot decide how to merge, simply throw the NoConflictResultException
. In that case, the library will ignore the result and proceed to merge as if no conflict resolver was present. It's basically this methods equivalent of returning an empty JSON object on the non generic variant of this method.