diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-12-17 08:27:31 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-12-17 08:27:31 +0100 |
commit | 1c7e8fd482bb67a5487449948488bd286a3504c1 (patch) | |
tree | 38789d22037a0b2ed7550b60fd2280fa522c086d /common/pipeline.h | |
parent | 7265d88245767960f1b551bb57f8f84942b898d2 (diff) | |
download | sink-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.h | 80 |
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 | ||
26 | namespace Akonadi2 | 31 | namespace Akonadi2 |
27 | { | 32 | { |
28 | 33 | ||
29 | class AKONADI2COMMON_EXPORT Pipeline | 34 | class PipelineState; |
35 | class PipelineFilter; | ||
36 | |||
37 | class AKONADI2COMMON_EXPORT Pipeline : public QObject | ||
30 | { | 38 | { |
39 | Q_OBJECT | ||
40 | |||
31 | public: | 41 | public: |
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 | |||
55 | Q_SIGNALS: | ||
56 | void revisionUpdated(); | ||
57 | |||
58 | private Q_SLOTS: | ||
59 | void stepPipelines(); | ||
60 | |||
61 | private: | ||
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 | |||
72 | class AKONADI2COMMON_EXPORT PipelineState | ||
73 | { | ||
74 | public: | ||
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 | |||
91 | private: | ||
92 | class Private; | ||
93 | QExplicitlySharedDataPointer<Private> d; | ||
94 | }; | ||
95 | |||
96 | class AKONADI2COMMON_EXPORT PipelineFilter | ||
97 | { | ||
98 | public: | ||
99 | PipelineFilter(); | ||
100 | virtual ~PipelineFilter(); | ||
101 | |||
102 | virtual void process(PipelineState state); | ||
103 | |||
104 | protected: | ||
105 | void processingCompleted(PipelineState state); | ||
40 | 106 | ||
41 | private: | 107 | private: |
42 | class Private; | 108 | class Private; |