summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/domain/event.cpp20
-rw-r--r--common/domain/event.h9
-rw-r--r--common/domainadaptor.h16
-rw-r--r--examples/dummyresource/domainadaptor.h2
-rw-r--r--tests/domainadaptortest.cpp2
5 files changed, 21 insertions, 28 deletions
diff --git a/common/domain/event.cpp b/common/domain/event.cpp
index ea0931c..776fa50 100644
--- a/common/domain/event.cpp
+++ b/common/domain/event.cpp
@@ -56,28 +56,28 @@ void TypeImplementation<Event>::index(const Event &type)
56 } 56 }
57} 57}
58 58
59QSharedPointer<ReadPropertyMapper<Buffer::Event> > TypeImplementation<Event>::initializeReadPropertyMapper() 59QSharedPointer<ReadPropertyMapper<TypeImplementation<Event>::Buffer> > TypeImplementation<Event>::initializeReadPropertyMapper()
60{ 60{
61 auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer::Event> >::create(); 61 auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create();
62 propertyMapper->addMapping("summary", [](Buffer::Event const *buffer) -> QVariant { 62 propertyMapper->addMapping("summary", [](Buffer const *buffer) -> QVariant {
63 return propertyToVariant<QString>(buffer->summary()); 63 return propertyToVariant<QString>(buffer->summary());
64 }); 64 });
65 propertyMapper->addMapping("uid", [](Buffer::Event const *buffer) -> QVariant { 65 propertyMapper->addMapping("uid", [](Buffer const *buffer) -> QVariant {
66 return propertyToVariant<QString>(buffer->uid()); 66 return propertyToVariant<QString>(buffer->uid());
67 }); 67 });
68 return propertyMapper; 68 return propertyMapper;
69} 69}
70 70
71QSharedPointer<WritePropertyMapper<Buffer::EventBuilder> > TypeImplementation<Event>::initializeWritePropertyMapper() 71QSharedPointer<WritePropertyMapper<TypeImplementation<Event>::BufferBuilder> > TypeImplementation<Event>::initializeWritePropertyMapper()
72{ 72{
73 auto propertyMapper = QSharedPointer<WritePropertyMapper<Buffer::EventBuilder> >::create(); 73 auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create();
74 propertyMapper->addMapping("summary", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Buffer::EventBuilder &)> { 74 propertyMapper->addMapping("summary", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> {
75 auto offset = variantToProperty<QString>(value, fbb); 75 auto offset = variantToProperty<QString>(value, fbb);
76 return [offset](Buffer::EventBuilder &builder) { builder.add_summary(offset); }; 76 return [offset](BufferBuilder &builder) { builder.add_summary(offset); };
77 }); 77 });
78 propertyMapper->addMapping("uid", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Buffer::EventBuilder &)> { 78 propertyMapper->addMapping("uid", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> {
79 auto offset = variantToProperty<QString>(value, fbb); 79 auto offset = variantToProperty<QString>(value, fbb);
80 return [offset](Buffer::EventBuilder &builder) { builder.add_uid(offset); }; 80 return [offset](BufferBuilder &builder) { builder.add_uid(offset); };
81 }); 81 });
82 return propertyMapper; 82 return propertyMapper;
83} 83}
diff --git a/common/domain/event.h b/common/domain/event.h
index d4ce20e..d40e55d 100644
--- a/common/domain/event.h
+++ b/common/domain/event.h
@@ -41,7 +41,10 @@ namespace ApplicationDomain {
41 * Implements all type-specific code such as updating and querying indexes. 41 * Implements all type-specific code such as updating and querying indexes.
42 */ 42 */
43template<> 43template<>
44struct TypeImplementation<Akonadi2::ApplicationDomain::Event> { 44class TypeImplementation<Akonadi2::ApplicationDomain::Event> {
45public:
46 typedef Akonadi2::ApplicationDomain::Buffer::Event Buffer;
47 typedef Akonadi2::ApplicationDomain::Buffer::EventBuilder BufferBuilder;
45 /** 48 /**
46 * Returns the potential result set based on the indexes. 49 * Returns the potential result set based on the indexes.
47 * 50 *
@@ -49,8 +52,8 @@ struct TypeImplementation<Akonadi2::ApplicationDomain::Event> {
49 */ 52 */
50 static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier); 53 static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier);
51 static void index(const Event &type); 54 static void index(const Event &type);
52 static QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > initializeReadPropertyMapper(); 55 static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper();
53 static QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> > initializeWritePropertyMapper(); 56 static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper();
54}; 57};
55 58
56} 59}
diff --git a/common/domainadaptor.h b/common/domainadaptor.h
index 70c3a42..c9a3a01 100644
--- a/common/domainadaptor.h
+++ b/common/domainadaptor.h
@@ -25,7 +25,6 @@
25#include <functional> 25#include <functional>
26#include "clientapi.h" //for domain parts 26#include "clientapi.h" //for domain parts
27 27
28#include "event_generated.h"
29#include "entity_generated.h" 28#include "entity_generated.h"
30#include "metadata_generated.h" 29#include "metadata_generated.h"
31#include "entitybuffer.h" 30#include "entitybuffer.h"
@@ -103,17 +102,6 @@ public:
103 QSharedPointer<ReadPropertyMapper<ResourceBuffer> > mResourceMapper; 102 QSharedPointer<ReadPropertyMapper<ResourceBuffer> > mResourceMapper;
104}; 103};
105 104
106/**
107 * Initializes the local property mapper.
108 *
109 * Provide an implementation for each application domain type.
110 */
111template <class T>
112QSharedPointer<ReadPropertyMapper<T> > initializeReadPropertyMapper();
113
114template <class T>
115QSharedPointer<WritePropertyMapper<T> > initializeWritePropertyMapper();
116
117template<typename DomainType> 105template<typename DomainType>
118class DomainTypeAdaptorFactoryInterface 106class DomainTypeAdaptorFactoryInterface
119{ 107{
@@ -128,9 +116,11 @@ public:
128 * It defines how values are split accross local and resource buffer. 116 * It defines how values are split accross local and resource buffer.
129 * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. 117 * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way.
130 */ 118 */
131template<typename DomainType, typename LocalBuffer, typename ResourceBuffer, typename LocalBuilder, typename ResourceBuilder> 119template<typename DomainType, typename ResourceBuffer, typename ResourceBuilder>
132class DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface<DomainType> 120class DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface<DomainType>
133{ 121{
122 typedef typename Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer;
123 typedef typename Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::BufferBuilder LocalBuilder;
134public: 124public:
135 DomainTypeAdaptorFactory() : 125 DomainTypeAdaptorFactory() :
136 mLocalMapper(Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::initializeReadPropertyMapper()), 126 mLocalMapper(Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::initializeReadPropertyMapper()),
diff --git a/examples/dummyresource/domainadaptor.h b/examples/dummyresource/domainadaptor.h
index 9d351e7..0490387 100644
--- a/examples/dummyresource/domainadaptor.h
+++ b/examples/dummyresource/domainadaptor.h
@@ -5,7 +5,7 @@
5#include "dummycalendar_generated.h" 5#include "dummycalendar_generated.h"
6#include "entity_generated.h" 6#include "entity_generated.h"
7 7
8class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, DummyCalendar::DummyEvent, Akonadi2::ApplicationDomain::Buffer::EventBuilder, DummyCalendar::DummyEventBuilder> 8class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, DummyCalendar::DummyEvent, DummyCalendar::DummyEventBuilder>
9{ 9{
10public: 10public:
11 DummyEventAdaptorFactory(); 11 DummyEventAdaptorFactory();
diff --git a/tests/domainadaptortest.cpp b/tests/domainadaptortest.cpp
index 97a78c2..ccf9a3c 100644
--- a/tests/domainadaptortest.cpp
+++ b/tests/domainadaptortest.cpp
@@ -13,7 +13,7 @@
13#include "metadata_generated.h" 13#include "metadata_generated.h"
14#include "entity_generated.h" 14#include "entity_generated.h"
15 15
16class TestFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder, Akonadi2::ApplicationDomain::Buffer::EventBuilder> 16class TestFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder>
17{ 17{
18public: 18public:
19 TestFactory() 19 TestFactory()