summaryrefslogtreecommitdiffstats
path: root/common/clientapi.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2014-12-24 02:15:41 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2014-12-24 02:15:41 +0100
commitc83c2ef64b5a1e4b1dc0102df36687caebb96ff0 (patch)
tree7d0567996c02e9a1ea5909abbab5f68401fd4771 /common/clientapi.h
parentd80ff84c28c0be626c1df4528741cddf5a55f547 (diff)
downloadsink-c83c2ef64b5a1e4b1dc0102df36687caebb96ff0.tar.gz
sink-c83c2ef64b5a1e4b1dc0102df36687caebb96ff0.zip
unifying buffer, and a better way to implement domain object adapters.
Diffstat (limited to 'common/clientapi.h')
-rw-r--r--common/clientapi.h38
1 files changed, 27 insertions, 11 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index d2757e7..ba0cb19 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -173,18 +173,36 @@ namespace Akonadi2 {
173 */ 173 */
174namespace Domain { 174namespace Domain {
175 175
176/**
177 * This class has to be implemented by resources and can be used as generic interface to access the buffer properties
178 */
179class BufferAdaptor {
180public:
181 virtual QVariant getProperty(const QString &key) { return QVariant(); }
182 virtual void setProperty(const QString &key, const QVariant &value) {}
183};
184
185/**
186 * The domain type interface has two purposes:
187 * * provide a unified interface to read buffers (for zero-copy reading)
188 * * record changes to generate changesets for modifications
189 */
176class AkonadiDomainType { 190class AkonadiDomainType {
177public: 191public:
178 AkonadiDomainType(const QString &resourceName, const QString &identifier, qint64 revision) 192 AkonadiDomainType(const QString &resourceName, const QString &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor)
179 : mResourceName(resourceName), 193 : mAdaptor(adaptor),
194 mResourceName(resourceName),
180 mIdentifier(identifier), 195 mIdentifier(identifier),
181 mRevision(revision) 196 mRevision(revision)
182 { 197 {
183 } 198 }
184 199
185 virtual QVariant getProperty(const QString &key){ return QVariant(); } 200 virtual QVariant getProperty(const QString &key){ return mAdaptor->getProperty(key); }
201 virtual void setProperty(const QString &key, const QVariant &value){ mChangeSet.insert(key, value); }
186 202
187private: 203private:
204 QSharedPointer<BufferAdaptor> mAdaptor;
205 QHash<QString, QVariant> mChangeSet;
188 /* 206 /*
189 * Each domain object needs to store the resource, identifier, revision triple so we can link back to the storage location. 207 * Each domain object needs to store the resource, identifier, revision triple so we can link back to the storage location.
190 */ 208 */
@@ -193,21 +211,19 @@ private:
193 qint64 mRevision; 211 qint64 mRevision;
194}; 212};
195 213
196class Event : public AkonadiDomainType { 214struct Event : public AkonadiDomainType {
197public:
198 typedef QSharedPointer<Event> Ptr; 215 typedef QSharedPointer<Event> Ptr;
199 Event(const QString &resource, const QString &identifier, qint64 revision):AkonadiDomainType(resource, identifier, revision){}; 216 using AkonadiDomainType::AkonadiDomainType;
200
201}; 217};
202 218
203class Todo : public AkonadiDomainType { 219struct Todo : public AkonadiDomainType {
204public:
205 typedef QSharedPointer<Todo> Ptr; 220 typedef QSharedPointer<Todo> Ptr;
221 using AkonadiDomainType::AkonadiDomainType;
206}; 222};
207 223
208class Calendar : public AkonadiDomainType { 224struct Calendar : public AkonadiDomainType {
209public:
210 typedef QSharedPointer<Calendar> Ptr; 225 typedef QSharedPointer<Calendar> Ptr;
226 using AkonadiDomainType::AkonadiDomainType;
211}; 227};
212 228
213class Mail : public AkonadiDomainType { 229class Mail : public AkonadiDomainType {