diff options
Diffstat (limited to 'common/pipeline.cpp')
-rw-r--r-- | common/pipeline.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index feceb77..034f913 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -52,7 +52,7 @@ public: | |||
52 | 52 | ||
53 | Storage storage; | 53 | Storage storage; |
54 | Storage::Transaction transaction; | 54 | Storage::Transaction transaction; |
55 | QHash<QString, QVector<Preprocessor *>> processors; | 55 | QHash<QString, QVector<QSharedPointer<Preprocessor>>> processors; |
56 | bool revisionChanged; | 56 | bool revisionChanged; |
57 | void storeNewRevision(qint64 newRevision, const flatbuffers::FlatBufferBuilder &fbb, const QByteArray &bufferType, const QByteArray &uid); | 57 | void storeNewRevision(qint64 newRevision, const flatbuffers::FlatBufferBuilder &fbb, const QByteArray &bufferType, const QByteArray &uid); |
58 | QTime transactionTime; | 58 | QTime transactionTime; |
@@ -80,18 +80,16 @@ Pipeline::Pipeline(const QString &resourceName, QObject *parent) : QObject(paren | |||
80 | Pipeline::~Pipeline() | 80 | Pipeline::~Pipeline() |
81 | { | 81 | { |
82 | d->transaction = Storage::Transaction(); | 82 | d->transaction = Storage::Transaction(); |
83 | for (const auto &t : d->processors.keys()) { | ||
84 | qDeleteAll(d->processors.value(t)); | ||
85 | } | ||
86 | delete d; | ||
87 | } | 83 | } |
88 | 84 | ||
89 | void Pipeline::setPreprocessors(const QString &entityType, const QVector<Preprocessor *> &processors) | 85 | void Pipeline::setPreprocessors(const QString &entityType, const QVector<Preprocessor *> &processors) |
90 | { | 86 | { |
87 | auto &list = d->processors[entityType]; | ||
88 | list.clear(); | ||
91 | for (auto p : processors) { | 89 | for (auto p : processors) { |
92 | p->setup(d->resourceType, d->resourceInstanceIdentifier, this); | 90 | p->setup(d->resourceType, d->resourceInstanceIdentifier, this); |
91 | list.append(QSharedPointer<Preprocessor>(p)); | ||
93 | } | 92 | } |
94 | d->processors[entityType] = processors; | ||
95 | } | 93 | } |
96 | 94 | ||
97 | void Pipeline::setResourceType(const QByteArray &resourceType) | 95 | void Pipeline::setResourceType(const QByteArray &resourceType) |
@@ -216,7 +214,7 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | |||
216 | 214 | ||
217 | auto adaptor = adaptorFactory->createAdaptor(*entity); | 215 | auto adaptor = adaptorFactory->createAdaptor(*entity); |
218 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(*(adaptor), adaptor->availableProperties()); | 216 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(*(adaptor), adaptor->availableProperties()); |
219 | for (auto processor : d->processors[bufferType]) { | 217 | foreach (const auto &processor, d->processors[bufferType]) { |
220 | processor->newEntity(key, Storage::maxRevision(d->transaction) + 1, *memoryAdaptor, d->transaction); | 218 | processor->newEntity(key, Storage::maxRevision(d->transaction) + 1, *memoryAdaptor, d->transaction); |
221 | } | 219 | } |
222 | //The maxRevision may have changed meanwhile if the entity created sub-entities | 220 | //The maxRevision may have changed meanwhile if the entity created sub-entities |
@@ -325,7 +323,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
325 | } | 323 | } |
326 | 324 | ||
327 | newAdaptor->resetChangedProperties(); | 325 | newAdaptor->resetChangedProperties(); |
328 | for (auto processor : d->processors[bufferType]) { | 326 | foreach (const auto &processor, d->processors[bufferType]) { |
329 | processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); | 327 | processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); |
330 | } | 328 | } |
331 | //The maxRevision may have changed meanwhile if the entity created sub-entities | 329 | //The maxRevision may have changed meanwhile if the entity created sub-entities |
@@ -432,7 +430,7 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
432 | 430 | ||
433 | d->storeNewRevision(newRevision, fbb, bufferType, key); | 431 | d->storeNewRevision(newRevision, fbb, bufferType, key); |
434 | 432 | ||
435 | for (auto processor : d->processors[bufferType]) { | 433 | foreach (const auto &processor, d->processors[bufferType]) { |
436 | processor->deletedEntity(key, newRevision, *current, d->transaction); | 434 | processor->deletedEntity(key, newRevision, *current, d->transaction); |
437 | } | 435 | } |
438 | 436 | ||
@@ -485,7 +483,6 @@ Preprocessor::Preprocessor() : d(new Preprocessor::Private) | |||
485 | 483 | ||
486 | Preprocessor::~Preprocessor() | 484 | Preprocessor::~Preprocessor() |
487 | { | 485 | { |
488 | delete d; | ||
489 | } | 486 | } |
490 | 487 | ||
491 | void Preprocessor::setup(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier, Pipeline *pipeline) | 488 | void Preprocessor::setup(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier, Pipeline *pipeline) |