1 #ifndef QTDATASYNC_EVENTCURSOR_H 2 #define QTDATASYNC_EVENTCURSOR_H 6 #include <QtCore/qobject.h> 7 #include <QtCore/qscopedpointer.h> 8 #include <QtCore/qdatetime.h> 9 #include <QtCore/qbytearray.h> 11 #include "QtDataSync/qtdatasync_global.h" 12 #include "QtDataSync/objectkey.h" 13 #include "QtDataSync/exception.h" 17 class EventCursorPrivate;
24 Q_PROPERTY(
bool valid READ isValid CONSTANT)
26 Q_PROPERTY(
QString setupName READ setupName CONSTANT)
29 Q_PROPERTY(quint64 index READ index NOTIFY indexChanged USER true)
33 Q_PROPERTY(
bool wasRemoved READ wasRemoved NOTIFY wasRemovedChanged)
35 Q_PROPERTY(
QDateTime timestamp READ timestamp NOTIFY timestampChanged)
38 Q_PROPERTY(
bool skipObsolete READ skipObsolete WRITE setSkipObsolete NOTIFY skipObsoleteChanged)
71 quint64 index() const;
75 bool wasRemoved() const;
80 bool skipObsolete() const;
83 Q_INVOKABLE
bool hasNext() const;
85 Q_INVOKABLE
bool next();
88 Q_INVOKABLE
void autoScanLog();
90 void autoScanLog(
std::function<
bool(const
EventCursor *)> function,
bool scanCurrent = true);
92 void autoScanLog(
QObject *scope,
std::function<
bool(const
EventCursor *)> function,
bool scanCurrent = true);
94 template <typename TClass>
95 void autoScanLog(TClass *scope,
bool(TClass::* function)(const
EventCursor *),
bool scanCurrent = true);
99 void setSkipObsolete(
bool skipObsolete);
102 void clearEventLog(quint64 offset = 0);
106 void eventLogChanged(QPrivateSignal);
109 void indexChanged(quint64 index, QPrivateSignal);
113 void wasRemovedChanged(
bool wasRemoved, QPrivateSignal);
115 void timestampChanged(const
QDateTime ×tamp, QPrivateSignal);
117 void skipObsoleteChanged(
bool skipObsolete, QPrivateSignal);
137 quint64 index()
const;
141 QByteArray className()
const noexcept
override;
142 QString qWhat()
const override;
143 void raise()
const override;
159 template<
typename TClass>
162 static_assert(std::is_base_of<QObject, TClass>::value,
"TClass must extend QObject");
163 autoScanLog(scope, [scope,
function](
const EventCursor *cursor) ->
bool {
164 return (scope->*
function)(cursor);
170 #endif // QTDATASYNC_EVENTCURSOR_H
Q_INVOKABLE void autoScanLog()
Automatically scans though all change events.
The base class for all exceptions of QtDataSync.
Defines a unique key to identify a dataset globally.
The primary namespace of the QtDataSync library.
Q_DATASYNC_EXPORT const QString DefaultSetup
The default setup name.
A cursor style class to read from the global change event log.
A helper class to get defaults per datasync instance (threadsafe)
Exception thrown from the event cursor if something goes wrong.