summaryrefslogtreecommitdiffstats
path: root/common/pipeline.h
diff options
context:
space:
mode:
authorAaron Seigo <aseigo@kde.org>2014-12-17 08:27:31 +0100
committerAaron Seigo <aseigo@kde.org>2014-12-17 08:27:31 +0100
commit1c7e8fd482bb67a5487449948488bd286a3504c1 (patch)
tree38789d22037a0b2ed7550b60fd2280fa522c086d /common/pipeline.h
parent7265d88245767960f1b551bb57f8f84942b898d2 (diff)
downloadsink-1c7e8fd482bb67a5487449948488bd286a3504c1.tar.gz
sink-1c7e8fd482bb67a5487449948488bd286a3504c1.zip
a basically-working Pipeline implementation
still a skeleton rather than a full body with flesh and blood, but it is getting there!
Diffstat (limited to 'common/pipeline.h')
-rw-r--r--common/pipeline.h80
1 files changed, 73 insertions, 7 deletions
diff --git a/common/pipeline.h b/common/pipeline.h
index 635e630..6ad78df 100644
--- a/common/pipeline.h
+++ b/common/pipeline.h
@@ -20,23 +20,89 @@
20 20
21#pragma once 21#pragma once
22 22
23#include <flatbuffers/flatbuffers.h>
24
25#include <QSharedDataPointer>
26#include <QObject>
27
23#include <akonadi2common_export.h> 28#include <akonadi2common_export.h>
24#include <storage.h> 29#include <storage.h>
25 30
26namespace Akonadi2 31namespace Akonadi2
27{ 32{
28 33
29class AKONADI2COMMON_EXPORT Pipeline 34class PipelineState;
35class PipelineFilter;
36
37class AKONADI2COMMON_EXPORT Pipeline : public QObject
30{ 38{
39 Q_OBJECT
40
31public: 41public:
32 Pipeline(const QString &storagePath); 42 enum Type { NullPipeline, NewPipeline, ModifiedPipeline, DeletedPipeline };
43
44 Pipeline(const QString &storagePath, QObject *parent = 0);
33 ~Pipeline(); 45 ~Pipeline();
34 46
35 Storage &storage(); 47 Storage &storage() const;
36 void null(uint messageId, const char *key, size_t keySize, const char *buffer, size_t bufferSize); 48
37 void newEntity(uint messageId, const char *key, size_t keySize, const char *buffer, size_t bufferSize); 49 // domain objects needed here
38 void modifiedEntity(uint messageId, const char *key, size_t keySize, const char *buffer, size_t bufferSize); 50 void null();
39 void deletedEntity(uint messageId, const char *key, size_t keySize, const char *buffer, size_t bufferSize); 51 void newEntity(const QByteArray &key, flatbuffers::FlatBufferBuilder &entity);
52 void modifiedEntity(const QByteArray &key, flatbuffers::FlatBufferBuilder &entityDelta);
53 void deletedEntity(const QByteArray &key);
54
55Q_SIGNALS:
56 void revisionUpdated();
57
58private Q_SLOTS:
59 void stepPipelines();
60
61private:
62 void pipelineStepped(const PipelineState &state);
63 void pipelineCompleted(const PipelineState &state);
64 void scheduleStep();
65
66 friend class PipelineState;
67
68 class Private;
69 Private * const d;
70};
71
72class AKONADI2COMMON_EXPORT PipelineState
73{
74public:
75 // domain objects?
76 PipelineState();
77 PipelineState(Pipeline *pipeline, Pipeline::Type type, const QByteArray &key, const QVector<PipelineFilter *> &filters);
78 PipelineState(const PipelineState &other);
79 ~PipelineState();
80
81 PipelineState &operator=(const PipelineState &rhs);
82 bool operator==(const PipelineState &rhs);
83
84 bool isIdle() const;
85 QByteArray key() const;
86 Pipeline::Type type() const;
87
88 void step();
89 void processingCompleted(PipelineFilter *filter);
90
91private:
92 class Private;
93 QExplicitlySharedDataPointer<Private> d;
94};
95
96class AKONADI2COMMON_EXPORT PipelineFilter
97{
98public:
99 PipelineFilter();
100 virtual ~PipelineFilter();
101
102 virtual void process(PipelineState state);
103
104protected:
105 void processingCompleted(PipelineState state);
40 106
41private: 107private:
42 class Private; 108 class Private;