From 91d915a09b7d52c10edb1d4c1298fc2885b8a257 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 2 Jan 2015 22:39:25 +0100 Subject: DomainTypeAdaptor factory, per type preprocessor pipeline configuration. --- dummyresource/facade.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'dummyresource/facade.h') diff --git a/dummyresource/facade.h b/dummyresource/facade.h index c76e62c..46b27ef 100644 --- a/dummyresource/facade.h +++ b/dummyresource/facade.h @@ -21,11 +21,63 @@ #include "common/clientapi.h" #include "common/storage.h" +#include "entity_generated.h" +#include "event_generated.h" +#include "dummycalendar_generated.h" namespace Akonadi2 { class ResourceAccess; } +/** + * The property mapper holds accessor functions for all properties. + * + * It is by default initialized with accessors that access the local-only buffer, + * and resource simply have to overwrite those accessors. + */ +template +class PropertyMapper +{ +public: + void setProperty(const QString &key, const QVariant &value, BufferType *buffer) + { + if (mWriteAccessors.contains(key)) { + auto accessor = mWriteAccessors.value(key); + return accessor(value, buffer); + } + } + + virtual QVariant getProperty(const QString &key, BufferType const *buffer) const + { + if (mReadAccessors.contains(key)) { + auto accessor = mReadAccessors.value(key); + return accessor(buffer); + } + return QVariant(); + } + QHash > mReadAccessors; + QHash > mWriteAccessors; +}; + +//The factory should define how to go from an entitybuffer (local + resource buffer), to a domain type adapter. +//It defines how values are split accross local and resource buffer. +//This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. +template +class DomainTypeAdaptorFactory +{ +}; + +template +class DomainTypeAdaptorFactory +{ +public: + QSharedPointer createAdaptor(const Akonadi2::Entity &entity); + +// private: + QSharedPointer > mLocalMapper; + QSharedPointer > mResourceMapper; +}; + class DummyResourceFacade : public Akonadi2::StoreFacade { public: @@ -39,4 +91,5 @@ public: private: void synchronizeResource(const std::function &continuation); QSharedPointer mResourceAccess; + QSharedPointer > mFactory; }; -- cgit v1.2.3