diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 09:01:05 +0100 |
commit | 4d9746c828558c9f872e0aed52442863affb25d5 (patch) | |
tree | 507d7c2ba67f47d3cbbcf01a722236ff1b48426b /common/genericresource.h | |
parent | 9cea920b7dd51867a0be0fed2f461b6be73c103e (diff) | |
download | sink-4d9746c828558c9f872e0aed52442863affb25d5.tar.gz sink-4d9746c828558c9f872e0aed52442863affb25d5.zip |
Fromatted the whole codebase with clang-format.
clang-format -i */**{.cpp,.h}
Diffstat (limited to 'common/genericresource.h')
-rw-r--r-- | common/genericresource.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/common/genericresource.h b/common/genericresource.h index b9bb994..9665d6b 100644 --- a/common/genericresource.h +++ b/common/genericresource.h | |||
@@ -29,8 +29,7 @@ | |||
29 | class CommandProcessor; | 29 | class CommandProcessor; |
30 | class ChangeReplay; | 30 | class ChangeReplay; |
31 | 31 | ||
32 | namespace Sink | 32 | namespace Sink { |
33 | { | ||
34 | class Pipeline; | 33 | class Pipeline; |
35 | class Preprocessor; | 34 | class Preprocessor; |
36 | 35 | ||
@@ -48,7 +47,8 @@ public: | |||
48 | virtual KAsync::Job<void> synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore); | 47 | virtual KAsync::Job<void> synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore); |
49 | virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; | 48 | virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; |
50 | virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE; | 49 | virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE; |
51 | virtual KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue); | 50 | virtual KAsync::Job<void> |
51 | inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue); | ||
52 | 52 | ||
53 | int error() const; | 53 | int error() const; |
54 | 54 | ||
@@ -61,13 +61,15 @@ private slots: | |||
61 | 61 | ||
62 | protected: | 62 | protected: |
63 | void enableChangeReplay(bool); | 63 | void enableChangeReplay(bool); |
64 | void addType(const QByteArray &type, DomainTypeAdaptorFactoryInterface::Ptr factory, const QVector<Sink::Preprocessor*> &preprocessors); | 64 | void addType(const QByteArray &type, DomainTypeAdaptorFactoryInterface::Ptr factory, const QVector<Sink::Preprocessor *> &preprocessors); |
65 | virtual KAsync::Job<void> replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value); | 65 | virtual KAsync::Job<void> replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value); |
66 | void onProcessorError(int errorCode, const QString &errorMessage); | 66 | void onProcessorError(int errorCode, const QString &errorMessage); |
67 | void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data); | 67 | void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data); |
68 | 68 | ||
69 | static void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); | 69 | static void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, |
70 | static void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); | 70 | DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); |
71 | static void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, | ||
72 | DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); | ||
71 | static void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback); | 73 | static void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback); |
72 | 74 | ||
73 | /** | 75 | /** |
@@ -79,36 +81,38 @@ protected: | |||
79 | 81 | ||
80 | /** | 82 | /** |
81 | * Tries to find a local id for the remote id, and creates a new local id otherwise. | 83 | * Tries to find a local id for the remote id, and creates a new local id otherwise. |
82 | * | 84 | * |
83 | * The new local id is recorded in the local to remote id mapping. | 85 | * The new local id is recorded in the local to remote id mapping. |
84 | */ | 86 | */ |
85 | QByteArray resolveRemoteId(const QByteArray &type, const QByteArray &remoteId, Sink::Storage::Transaction &transaction); | 87 | QByteArray resolveRemoteId(const QByteArray &type, const QByteArray &remoteId, Sink::Storage::Transaction &transaction); |
86 | 88 | ||
87 | /** | 89 | /** |
88 | * Tries to find a remote id for a local id. | 90 | * Tries to find a remote id for a local id. |
89 | * | 91 | * |
90 | * This can fail if the entity hasn't been written back to the server yet. | 92 | * This can fail if the entity hasn't been written back to the server yet. |
91 | */ | 93 | */ |
92 | QByteArray resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Sink::Storage::Transaction &transaction); | 94 | QByteArray resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Sink::Storage::Transaction &transaction); |
93 | 95 | ||
94 | /** | 96 | /** |
95 | * A synchronous algorithm to remove entities that are no longer existing. | 97 | * A synchronous algorithm to remove entities that are no longer existing. |
96 | * | 98 | * |
97 | * A list of entities is generated by @param entryGenerator. | 99 | * A list of entities is generated by @param entryGenerator. |
98 | * The entiry Generator typically iterates over an index to produce all existing entries. | 100 | * The entiry Generator typically iterates over an index to produce all existing entries. |
99 | * This algorithm calls @param exists for every entity of type @param type, with its remoteId. For every entity where @param exists returns false, | 101 | * This algorithm calls @param exists for every entity of type @param type, with its remoteId. For every entity where @param exists returns false, |
100 | * an entity delete command is enqueued. | 102 | * an entity delete command is enqueued. |
101 | * | 103 | * |
102 | * All functions are called synchronously, and both @param entryGenerator and @param exists need to be synchronous. | 104 | * All functions are called synchronously, and both @param entryGenerator and @param exists need to be synchronous. |
103 | */ | 105 | */ |
104 | void scanForRemovals(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists); | 106 | void scanForRemovals(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, |
107 | const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists); | ||
105 | 108 | ||
106 | /** | 109 | /** |
107 | * An algorithm to create or modify the entity. | 110 | * An algorithm to create or modify the entity. |
108 | * | 111 | * |
109 | * Depending on whether the entity is locally available, or has changed. | 112 | * Depending on whether the entity is locally available, or has changed. |
110 | */ | 113 | */ |
111 | void createOrModify(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, const QByteArray &bufferType, const QByteArray &remoteId, const Sink::ApplicationDomain::ApplicationDomainType &entity); | 114 | void createOrModify(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, |
115 | const QByteArray &bufferType, const QByteArray &remoteId, const Sink::ApplicationDomain::ApplicationDomainType &entity); | ||
112 | 116 | ||
113 | MessageQueue mUserQueue; | 117 | MessageQueue mUserQueue; |
114 | MessageQueue mSynchronizerQueue; | 118 | MessageQueue mSynchronizerQueue; |
@@ -122,5 +126,4 @@ private: | |||
122 | QTimer mCommitQueueTimer; | 126 | QTimer mCommitQueueTimer; |
123 | qint64 mClientLowerBoundRevision; | 127 | qint64 mClientLowerBoundRevision; |
124 | }; | 128 | }; |
125 | |||
126 | } | 129 | } |