diff options
Diffstat (limited to 'common/pipeline.cpp')
-rw-r--r-- | common/pipeline.cpp | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 04954ac..8d00480 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -41,10 +41,10 @@ public: | |||
41 | } | 41 | } |
42 | 42 | ||
43 | Storage storage; | 43 | Storage storage; |
44 | QVector<Preprocessor *> nullPipeline; | 44 | QHash<QString, QVector<Preprocessor *> > nullPipeline; |
45 | QVector<Preprocessor *> newPipeline; | 45 | QHash<QString, QVector<Preprocessor *> > newPipeline; |
46 | QVector<Preprocessor *> modifiedPipeline; | 46 | QHash<QString, QVector<Preprocessor *> > modifiedPipeline; |
47 | QVector<Preprocessor *> deletedPipeline; | 47 | QHash<QString, QVector<Preprocessor *> > deletedPipeline; |
48 | QVector<PipelineState> activePipelines; | 48 | QVector<PipelineState> activePipelines; |
49 | bool stepScheduled; | 49 | bool stepScheduled; |
50 | }; | 50 | }; |
@@ -60,6 +60,23 @@ Pipeline::~Pipeline() | |||
60 | delete d; | 60 | delete d; |
61 | } | 61 | } |
62 | 62 | ||
63 | void Pipeline::setPreprocessors(const QString &entityType, Type pipelineType, const QVector<Preprocessor *> &preprocessors) | ||
64 | { | ||
65 | switch (pipelineType) { | ||
66 | case NewPipeline: | ||
67 | d->newPipeline[entityType] = preprocessors; | ||
68 | break; | ||
69 | case ModifiedPipeline: | ||
70 | d->modifiedPipeline[entityType] = preprocessors; | ||
71 | break; | ||
72 | case DeletedPipeline: | ||
73 | d->deletedPipeline[entityType] = preprocessors; | ||
74 | break; | ||
75 | default: | ||
76 | break; | ||
77 | }; | ||
78 | } | ||
79 | |||
63 | Storage &Pipeline::storage() const | 80 | Storage &Pipeline::storage() const |
64 | { | 81 | { |
65 | return d->storage; | 82 | return d->storage; |
@@ -68,12 +85,12 @@ Storage &Pipeline::storage() const | |||
68 | void Pipeline::null() | 85 | void Pipeline::null() |
69 | { | 86 | { |
70 | //TODO: is there really any need for the null pipeline? if so, it should be doing something ;) | 87 | //TODO: is there really any need for the null pipeline? if so, it should be doing something ;) |
71 | PipelineState state(this, NullPipeline, QByteArray(), d->nullPipeline); | 88 | // PipelineState state(this, NullPipeline, QByteArray(), d->nullPipeline); |
72 | d->activePipelines << state; | 89 | // d->activePipelines << state; |
73 | state.step(); | 90 | // state.step(); |
74 | } | 91 | } |
75 | 92 | ||
76 | void Pipeline::newEntity(const QByteArray &key, void *resourceBufferData, size_t size) | 93 | void Pipeline::newEntity(const QString &entityType, const QByteArray &key, void *resourceBufferData, size_t size) |
77 | { | 94 | { |
78 | const qint64 newRevision = storage().maxRevision() + 1; | 95 | const qint64 newRevision = storage().maxRevision() + 1; |
79 | 96 | ||
@@ -81,6 +98,7 @@ void Pipeline::newEntity(const QByteArray &key, void *resourceBufferData, size_t | |||
81 | flatbuffers::FlatBufferBuilder metadataFbb; | 98 | flatbuffers::FlatBufferBuilder metadataFbb; |
82 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 99 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); |
83 | metadataBuilder.add_revision(newRevision); | 100 | metadataBuilder.add_revision(newRevision); |
101 | metadataBuilder.add_processed(false); | ||
84 | auto metadataBuffer = metadataBuilder.Finish(); | 102 | auto metadataBuffer = metadataBuilder.Finish(); |
85 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 103 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
86 | 104 | ||
@@ -90,21 +108,21 @@ void Pipeline::newEntity(const QByteArray &key, void *resourceBufferData, size_t | |||
90 | storage().write(key.data(), key.size(), fbb.GetBufferPointer(), fbb.GetSize()); | 108 | storage().write(key.data(), key.size(), fbb.GetBufferPointer(), fbb.GetSize()); |
91 | storage().setMaxRevision(newRevision); | 109 | storage().setMaxRevision(newRevision); |
92 | 110 | ||
93 | PipelineState state(this, NewPipeline, key, d->newPipeline); | 111 | PipelineState state(this, NewPipeline, key, d->newPipeline[entityType]); |
94 | d->activePipelines << state; | 112 | d->activePipelines << state; |
95 | state.step(); | 113 | state.step(); |
96 | } | 114 | } |
97 | 115 | ||
98 | void Pipeline::modifiedEntity(const QByteArray &key, void *data, size_t size) | 116 | void Pipeline::modifiedEntity(const QString &entityType, const QByteArray &key, void *data, size_t size) |
99 | { | 117 | { |
100 | PipelineState state(this, ModifiedPipeline, key, d->modifiedPipeline); | 118 | PipelineState state(this, ModifiedPipeline, key, d->modifiedPipeline[entityType]); |
101 | d->activePipelines << state; | 119 | d->activePipelines << state; |
102 | state.step(); | 120 | state.step(); |
103 | } | 121 | } |
104 | 122 | ||
105 | void Pipeline::deletedEntity(const QByteArray &key) | 123 | void Pipeline::deletedEntity(const QString &entityType, const QByteArray &key) |
106 | { | 124 | { |
107 | PipelineState state(this, DeletedPipeline, key, d->deletedPipeline); | 125 | PipelineState state(this, DeletedPipeline, key, d->deletedPipeline[entityType]); |
108 | d->activePipelines << state; | 126 | d->activePipelines << state; |
109 | state.step(); | 127 | state.step(); |
110 | } | 128 | } |