1 #ifndef QTDATASYNC_CONFLICTRESOLVER_H 2 #define QTDATASYNC_CONFLICTRESOLVER_H 4 #include <QtCore/qobject.h> 5 #include <QtCore/qscopedpointer.h> 7 #include <QtJsonSerializer/qjsonserializer.h> 9 #include "QtDataSync/qtdatasync_global.h" 10 #include "QtDataSync/defaults.h" 11 #include "QtDataSync/logger.h" 15 class ConflictResolverPrivate;
27 void setDefaults(
const Defaults &defaults);
49 template <
typename T1,
typename... Args>
60 if(typeId == qMetaTypeId<T1>()) {
67 }
catch(NoConflictResultException&) {
107 template <
typename T1>
117 if(typeId == qMetaTypeId<T1>()) {
124 }
catch(NoConflictResultException&) {
128 return resolveUnknownConflict(typeId, data1, data2);
133 class NoConflictResultException {};
173 QT_DATASYNC_LOG_BASE.warning(logger()->loggingCategory()) <<
"Unsupported type in conflict resolver:" 181 #endif // QTDATASYNC_CONFLICTRESOLVER_H QJsonObject resolveConflict(int typeId, const QJsonObject &data1, const QJsonObject &data2) const override
The method called to resolve conflicts between two datasets.
#define QT_DATASYNC_LOG_BASE
Internal macro.
virtual QJsonObject resolveUnknownConflict(int typeId, const QJsonObject &data1, const QJsonObject &data2) const
QJsonObject resolveConflict(int typeId, const QJsonObject &data1, const QJsonObject &data2) const override
The method called to resolve conflicts between two datasets.
A generic variant of the ConflictResolver to handel dataobjects instead of json data.
The primary namespace of the QtDataSync library.
GenericConflictResolver(QObject *parent=nullptr)
Default constructor.
QVariant deserialize(const QJsonValue &json, int metaTypeId, QObject *parent=nullptr) const
GenericConflictResolver(QObject *parent=nullptr)
Default constructor.
Interface to implement a custom conflict handler for sync conflicts.
A helper class to get defaults per datasync instance (threadsafe)
QJsonValue serialize(const QVariant &data) const
A Helper class for simple and structured logging.