diff options
-rw-r--r-- | common/domain/applicationdomaintype.h | 94 | ||||
-rw-r--r-- | common/domain/event.cpp | 16 | ||||
-rw-r--r-- | common/domain/folder.cpp | 16 | ||||
-rw-r--r-- | common/domain/mail.cpp | 41 | ||||
-rw-r--r-- | common/propertymapper.h | 50 | ||||
-rw-r--r-- | examples/dummyresource/domainadaptor.cpp | 7 |
6 files changed, 141 insertions, 83 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index eadad00..4eec4a3 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -23,12 +23,56 @@ | |||
23 | #include <QSharedPointer> | 23 | #include <QSharedPointer> |
24 | #include <QVariant> | 24 | #include <QVariant> |
25 | #include <QByteArray> | 25 | #include <QByteArray> |
26 | #include <QDateTime> | ||
26 | #include <QDebug> | 27 | #include <QDebug> |
27 | #include <QUuid> | 28 | #include <QUuid> |
28 | #include "bufferadaptor.h" | 29 | #include "bufferadaptor.h" |
29 | 30 | ||
30 | namespace Sink { | 31 | #define SINK_ENTITY(TYPE) \ |
32 | typedef QSharedPointer<TYPE> Ptr; \ | ||
33 | using Entity::Entity; \ | ||
34 | virtual ~TYPE(); \ | ||
35 | |||
36 | |||
37 | #define SINK_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | ||
38 | struct NAME { \ | ||
39 | static constexpr const char *name = #LOWERCASENAME; \ | ||
40 | typedef TYPE Type; \ | ||
41 | }; \ | ||
42 | void set##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | ||
43 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ | ||
44 | |||
45 | |||
46 | #define SINK_EXTRACTED_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | ||
47 | struct NAME { \ | ||
48 | static constexpr const char *name = #LOWERCASENAME; \ | ||
49 | typedef TYPE Type; \ | ||
50 | }; \ | ||
51 | void setExtracted##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | ||
52 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ | ||
53 | |||
54 | |||
55 | #define SINK_BLOB_PROPERTY(NAME, LOWERCASENAME) \ | ||
56 | struct NAME { \ | ||
57 | static constexpr const char *name = #LOWERCASENAME; \ | ||
58 | typedef QString Type; \ | ||
59 | }; \ | ||
60 | void set##NAME(const QByteArray &value) { setBlobProperty(NAME::name, value); } \ | ||
61 | void set##NAME##Path(const QString &path) { setProperty(NAME::name, QVariant::fromValue(path)); } \ | ||
62 | QByteArray get##NAME() const { return getBlobProperty(NAME::name); } \ | ||
63 | QString get##NAME##Path() const { return getProperty(NAME::name).value<QString>(); } \ | ||
64 | |||
65 | #define SINK_REFERENCE_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | ||
66 | struct NAME { \ | ||
67 | static constexpr const char *name = #LOWERCASENAME; \ | ||
68 | typedef QByteArray Type; \ | ||
69 | }; \ | ||
70 | void set##NAME(const ApplicationDomain::TYPE &value) { setProperty(NAME::name, value); } \ | ||
71 | void set##NAME(const QByteArray &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | ||
72 | QByteArray get##NAME() const { return getProperty(NAME::name).value<QByteArray>(); } \ | ||
73 | |||
31 | 74 | ||
75 | namespace Sink { | ||
32 | namespace ApplicationDomain { | 76 | namespace ApplicationDomain { |
33 | 77 | ||
34 | /** | 78 | /** |
@@ -128,33 +172,41 @@ struct SINK_EXPORT Entity : public ApplicationDomainType { | |||
128 | }; | 172 | }; |
129 | 173 | ||
130 | struct SINK_EXPORT Event : public Entity { | 174 | struct SINK_EXPORT Event : public Entity { |
131 | typedef QSharedPointer<Event> Ptr; | 175 | SINK_ENTITY(Event); |
132 | using Entity::Entity; | 176 | SINK_PROPERTY(QString, Uid, uid); |
133 | virtual ~Event(); | 177 | SINK_PROPERTY(QString, Summary, summary); |
178 | SINK_PROPERTY(QString, Description, description); | ||
179 | SINK_PROPERTY(QByteArray, Attachment, attachment); | ||
134 | }; | 180 | }; |
135 | 181 | ||
136 | struct SINK_EXPORT Todo : public Entity { | 182 | struct SINK_EXPORT Todo : public Entity { |
137 | typedef QSharedPointer<Todo> Ptr; | 183 | SINK_ENTITY(Todo); |
138 | using Entity::Entity; | ||
139 | virtual ~Todo(); | ||
140 | }; | 184 | }; |
141 | 185 | ||
142 | struct SINK_EXPORT Calendar : public Entity { | 186 | struct SINK_EXPORT Calendar : public Entity { |
143 | typedef QSharedPointer<Calendar> Ptr; | 187 | SINK_ENTITY(Calendar); |
144 | using Entity::Entity; | ||
145 | virtual ~Calendar(); | ||
146 | }; | 188 | }; |
147 | 189 | ||
148 | struct SINK_EXPORT Mail : public Entity { | 190 | struct SINK_EXPORT Folder : public Entity { |
149 | typedef QSharedPointer<Mail> Ptr; | 191 | SINK_ENTITY(Folder); |
150 | using Entity::Entity; | 192 | SINK_REFERENCE_PROPERTY(Folder, Parent, parent); |
151 | virtual ~Mail(); | 193 | SINK_PROPERTY(QString, Name, name); |
194 | SINK_PROPERTY(QByteArray, Icon, icon); | ||
195 | SINK_PROPERTY(QByteArrayList, SpecialPurpose, specialpurpose); | ||
152 | }; | 196 | }; |
153 | 197 | ||
154 | struct SINK_EXPORT Folder : public Entity { | 198 | struct SINK_EXPORT Mail : public Entity { |
155 | typedef QSharedPointer<Folder> Ptr; | 199 | SINK_ENTITY(Mail); |
156 | using Entity::Entity; | 200 | SINK_PROPERTY(QString, Uid, uid); |
157 | virtual ~Folder(); | 201 | SINK_EXTRACTED_PROPERTY(QString, Sender, sender); |
202 | SINK_EXTRACTED_PROPERTY(QString, SenderName, senderName); | ||
203 | SINK_EXTRACTED_PROPERTY(QString, Subject, subject); | ||
204 | SINK_EXTRACTED_PROPERTY(QDateTime, Date, date); | ||
205 | SINK_PROPERTY(bool, Unread, unread); | ||
206 | SINK_PROPERTY(bool, Important, important); | ||
207 | SINK_REFERENCE_PROPERTY(Folder, Folder, folder); | ||
208 | SINK_BLOB_PROPERTY(MimeMessage, mimeMessage); | ||
209 | SINK_PROPERTY(bool, Draft, draft); | ||
158 | }; | 210 | }; |
159 | 211 | ||
160 | /** | 212 | /** |
@@ -235,6 +287,12 @@ class SINK_EXPORT TypeImplementation; | |||
235 | } | 287 | } |
236 | } | 288 | } |
237 | 289 | ||
290 | #undef SINK_ENTITY | ||
291 | #undef SINK_PROPERTY | ||
292 | #undef SINK_EXTRACTED_PROPERTY | ||
293 | #undef SINK_BLOB_PROPERTY | ||
294 | #undef SINK_REFERENCE_PROPERTY | ||
295 | |||
238 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) | 296 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) |
239 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) | 297 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) |
240 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) | 298 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) |
diff --git a/common/domain/event.cpp b/common/domain/event.cpp index 96e2d44..0909bf1 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp | |||
@@ -68,19 +68,19 @@ void TypeImplementation<Event>::removeIndex(const QByteArray &identifier, const | |||
68 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Event>::Buffer> > TypeImplementation<Event>::initializeReadPropertyMapper() | 68 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Event>::Buffer> > TypeImplementation<Event>::initializeReadPropertyMapper() |
69 | { | 69 | { |
70 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); | 70 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); |
71 | propertyMapper->addMapping<QString, Buffer>("summary", &Buffer::summary); | 71 | propertyMapper->addMapping<Event::Summary, Buffer>(&Buffer::summary); |
72 | propertyMapper->addMapping<QString, Buffer>("description", &Buffer::description); | 72 | propertyMapper->addMapping<Event::Description, Buffer>(&Buffer::description); |
73 | propertyMapper->addMapping<QString, Buffer>("uid", &Buffer::uid); | 73 | propertyMapper->addMapping<Event::Uid, Buffer>(&Buffer::uid); |
74 | propertyMapper->addMapping<QByteArray, Buffer>("attachment", &Buffer::attachment); | 74 | propertyMapper->addMapping<Event::Attachment, Buffer>(&Buffer::attachment); |
75 | return propertyMapper; | 75 | return propertyMapper; |
76 | } | 76 | } |
77 | 77 | ||
78 | QSharedPointer<WritePropertyMapper<TypeImplementation<Event>::BufferBuilder> > TypeImplementation<Event>::initializeWritePropertyMapper() | 78 | QSharedPointer<WritePropertyMapper<TypeImplementation<Event>::BufferBuilder> > TypeImplementation<Event>::initializeWritePropertyMapper() |
79 | { | 79 | { |
80 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); | 80 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); |
81 | propertyMapper->addMapping<QString>("summary", &BufferBuilder::add_summary); | 81 | propertyMapper->addMapping<Event::Summary>(&BufferBuilder::add_summary); |
82 | propertyMapper->addMapping<QString>("description", &BufferBuilder::add_description); | 82 | propertyMapper->addMapping<Event::Description>(&BufferBuilder::add_description); |
83 | propertyMapper->addMapping<QString>("uid", &BufferBuilder::add_uid); | 83 | propertyMapper->addMapping<Event::Uid>(&BufferBuilder::add_uid); |
84 | propertyMapper->addMapping<QByteArray>("attachment", &BufferBuilder::add_attachment); | 84 | propertyMapper->addMapping<Event::Attachment>(&BufferBuilder::add_attachment); |
85 | return propertyMapper; | 85 | return propertyMapper; |
86 | } | 86 | } |
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index faad5a9..309ca3f 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp | |||
@@ -70,19 +70,19 @@ void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const | |||
70 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Folder>::Buffer> > TypeImplementation<Folder>::initializeReadPropertyMapper() | 70 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Folder>::Buffer> > TypeImplementation<Folder>::initializeReadPropertyMapper() |
71 | { | 71 | { |
72 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); | 72 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); |
73 | propertyMapper->addMapping<QByteArray, Buffer>("parent", &Buffer::parent); | 73 | propertyMapper->addMapping<Folder::Parent, Buffer>(&Buffer::parent); |
74 | propertyMapper->addMapping<QString, Buffer>("name", &Buffer::name); | 74 | propertyMapper->addMapping<Folder::Name, Buffer>(&Buffer::name); |
75 | propertyMapper->addMapping<QByteArray, Buffer>("icon", &Buffer::icon); | 75 | propertyMapper->addMapping<Folder::Icon, Buffer>(&Buffer::icon); |
76 | propertyMapper->addMapping<QByteArrayList, Buffer>("specialpurpose", &Buffer::specialpurpose); | 76 | propertyMapper->addMapping<Folder::SpecialPurpose, Buffer>(&Buffer::specialpurpose); |
77 | return propertyMapper; | 77 | return propertyMapper; |
78 | } | 78 | } |
79 | 79 | ||
80 | QSharedPointer<WritePropertyMapper<TypeImplementation<Folder>::BufferBuilder> > TypeImplementation<Folder>::initializeWritePropertyMapper() | 80 | QSharedPointer<WritePropertyMapper<TypeImplementation<Folder>::BufferBuilder> > TypeImplementation<Folder>::initializeWritePropertyMapper() |
81 | { | 81 | { |
82 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); | 82 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); |
83 | propertyMapper->addMapping<QByteArray>("parent", &BufferBuilder::add_parent); | 83 | propertyMapper->addMapping<Folder::Parent>(&BufferBuilder::add_parent); |
84 | propertyMapper->addMapping<QString>("name", &BufferBuilder::add_name); | 84 | propertyMapper->addMapping<Folder::Name>(&BufferBuilder::add_name); |
85 | propertyMapper->addMapping<QByteArray>("icon", &BufferBuilder::add_icon); | 85 | propertyMapper->addMapping<Folder::Icon>(&BufferBuilder::add_icon); |
86 | propertyMapper->addMapping<QByteArrayList>("specialpurpose", &BufferBuilder::add_specialpurpose); | 86 | propertyMapper->addMapping<Folder::SpecialPurpose>(&BufferBuilder::add_specialpurpose); |
87 | return propertyMapper; | 87 | return propertyMapper; |
88 | } | 88 | } |
diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index 2f3973a..706e410 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp | |||
@@ -75,31 +75,32 @@ void TypeImplementation<Mail>::removeIndex(const QByteArray &identifier, const B | |||
75 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Mail>::Buffer> > TypeImplementation<Mail>::initializeReadPropertyMapper() | 75 | QSharedPointer<ReadPropertyMapper<TypeImplementation<Mail>::Buffer> > TypeImplementation<Mail>::initializeReadPropertyMapper() |
76 | { | 76 | { |
77 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); | 77 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Buffer> >::create(); |
78 | propertyMapper->addMapping<QString, Buffer>("uid", &Buffer::uid); | 78 | propertyMapper->addMapping<Mail::Uid, Buffer>(&Buffer::uid); |
79 | propertyMapper->addMapping<QString, Buffer>("sender", &Buffer::sender); | 79 | propertyMapper->addMapping<Mail::Sender, Buffer>(&Buffer::sender); |
80 | propertyMapper->addMapping<QString, Buffer>("senderName", &Buffer::senderName); | 80 | propertyMapper->addMapping<Mail::SenderName, Buffer>(&Buffer::senderName); |
81 | propertyMapper->addMapping<QString, Buffer>("subject", &Buffer::subject); | 81 | propertyMapper->addMapping<Mail::Subject, Buffer>(&Buffer::subject); |
82 | propertyMapper->addMapping<QDateTime, Buffer>("date", &Buffer::date); | 82 | propertyMapper->addMapping<Mail::Date, Buffer>(&Buffer::date); |
83 | propertyMapper->addMapping<bool, Buffer>("unread", &Buffer::unread); | 83 | propertyMapper->addMapping<Mail::Unread, Buffer>(&Buffer::unread); |
84 | propertyMapper->addMapping<bool, Buffer>("important", &Buffer::important); | 84 | propertyMapper->addMapping<Mail::Important, Buffer>(&Buffer::important); |
85 | propertyMapper->addMapping<QByteArray, Buffer>("folder", &Buffer::folder); | 85 | propertyMapper->addMapping<Mail::Folder, Buffer>(&Buffer::folder); |
86 | propertyMapper->addMapping<QString, Buffer>("mimeMessage", &Buffer::mimeMessage); | 86 | propertyMapper->addMapping<Mail::MimeMessage, Buffer>(&Buffer::mimeMessage); |
87 | propertyMapper->addMapping<bool, Buffer>("draft", &Buffer::draft); | 87 | propertyMapper->addMapping<Mail::Draft, Buffer>(&Buffer::draft); |
88 | return propertyMapper; | 88 | return propertyMapper; |
89 | } | 89 | } |
90 | 90 | ||
91 | QSharedPointer<WritePropertyMapper<TypeImplementation<Mail>::BufferBuilder> > TypeImplementation<Mail>::initializeWritePropertyMapper() | 91 | QSharedPointer<WritePropertyMapper<TypeImplementation<Mail>::BufferBuilder> > TypeImplementation<Mail>::initializeWritePropertyMapper() |
92 | { | 92 | { |
93 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); | 93 | auto propertyMapper = QSharedPointer<WritePropertyMapper<BufferBuilder> >::create(); |
94 | propertyMapper->addMapping<QString>("uid", &BufferBuilder::add_uid); | 94 | |
95 | propertyMapper->addMapping<QString>("sender", &BufferBuilder::add_sender); | 95 | propertyMapper->addMapping<Mail::Uid>(&BufferBuilder::add_uid); |
96 | propertyMapper->addMapping<QString>("senderName", &BufferBuilder::add_senderName); | 96 | propertyMapper->addMapping<Mail::Sender>(&BufferBuilder::add_sender); |
97 | propertyMapper->addMapping<QString>("subject", &BufferBuilder::add_subject); | 97 | propertyMapper->addMapping<Mail::SenderName>(&BufferBuilder::add_senderName); |
98 | propertyMapper->addMapping<QDateTime>("date", &BufferBuilder::add_date); | 98 | propertyMapper->addMapping<Mail::Subject>(&BufferBuilder::add_subject); |
99 | propertyMapper->addMapping<bool>("unread", &BufferBuilder::add_unread); | 99 | propertyMapper->addMapping<Mail::Date>(&BufferBuilder::add_date); |
100 | propertyMapper->addMapping<bool>("important", &BufferBuilder::add_important); | 100 | propertyMapper->addMapping<Mail::Unread>(&BufferBuilder::add_unread); |
101 | propertyMapper->addMapping<QByteArray>("folder", &BufferBuilder::add_folder); | 101 | propertyMapper->addMapping<Mail::Important>(&BufferBuilder::add_important); |
102 | propertyMapper->addMapping<QString>("mimeMessage", &BufferBuilder::add_mimeMessage); | 102 | propertyMapper->addMapping<Mail::Folder>(&BufferBuilder::add_folder); |
103 | propertyMapper->addMapping<bool>("draft", &BufferBuilder::add_draft); | 103 | propertyMapper->addMapping<Mail::MimeMessage>(&BufferBuilder::add_mimeMessage); |
104 | propertyMapper->addMapping<Mail::Draft>(&BufferBuilder::add_draft); | ||
104 | return propertyMapper; | 105 | return propertyMapper; |
105 | } | 106 | } |
diff --git a/common/propertymapper.h b/common/propertymapper.h index edbc7f1..8227940 100644 --- a/common/propertymapper.h +++ b/common/propertymapper.h | |||
@@ -78,33 +78,33 @@ public: | |||
78 | } | 78 | } |
79 | 79 | ||
80 | template <typename T, typename Buffer> | 80 | template <typename T, typename Buffer> |
81 | void addMapping(const QByteArray &name, const flatbuffers::String *(Buffer::*f)() const) | 81 | void addMapping(const flatbuffers::String *(Buffer::*f)() const) |
82 | { | 82 | { |
83 | addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); }); | 83 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); |
84 | } | 84 | } |
85 | 85 | ||
86 | template <typename T, typename Buffer> | 86 | template <typename T, typename Buffer> |
87 | void addMapping(const QByteArray &name, uint8_t (Buffer::*f)() const) | 87 | void addMapping(uint8_t (Buffer::*f)() const) |
88 | { | 88 | { |
89 | addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); }); | 89 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); |
90 | } | 90 | } |
91 | 91 | ||
92 | template <typename T, typename Buffer> | 92 | template <typename T, typename Buffer> |
93 | void addMapping(const QByteArray &name, bool (Buffer::*f)() const) | 93 | void addMapping(bool (Buffer::*f)() const) |
94 | { | 94 | { |
95 | addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); }); | 95 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); |
96 | } | 96 | } |
97 | 97 | ||
98 | template <typename T, typename Buffer> | 98 | template <typename T, typename Buffer> |
99 | void addMapping(const QByteArray &name, const flatbuffers::Vector<uint8_t> *(Buffer::*f)() const) | 99 | void addMapping(const flatbuffers::Vector<uint8_t> *(Buffer::*f)() const) |
100 | { | 100 | { |
101 | addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); }); | 101 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); |
102 | } | 102 | } |
103 | 103 | ||
104 | template <typename T, typename Buffer> | 104 | template <typename T, typename Buffer> |
105 | void addMapping(const QByteArray &name, const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *(Buffer::*f)() const) | 105 | void addMapping(const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *(Buffer::*f)() const) |
106 | { | 106 | { |
107 | addMapping(name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<T>((buffer->*f)()); }); | 107 | addMapping(T::name, [f](Buffer const *buffer) -> QVariant { return propertyToVariant<typename T::Type>((buffer->*f)()); }); |
108 | } | 108 | } |
109 | 109 | ||
110 | private: | 110 | private: |
@@ -134,44 +134,44 @@ public: | |||
134 | } | 134 | } |
135 | 135 | ||
136 | template <typename T> | 136 | template <typename T> |
137 | void addMapping(const QByteArray &name, void (BufferBuilder::*f)(uint8_t)) | 137 | void addMapping(void (BufferBuilder::*f)(uint8_t)) |
138 | { | 138 | { |
139 | addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | 139 | addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { |
140 | return [value, f](BufferBuilder &builder) { (builder.*f)(value.value<T>()); }; | 140 | return [value, f](BufferBuilder &builder) { (builder.*f)(value.value<typename T::Type>()); }; |
141 | }); | 141 | }); |
142 | } | 142 | } |
143 | 143 | ||
144 | template <typename T> | 144 | template <typename T> |
145 | void addMapping(const QByteArray &name, void (BufferBuilder::*f)(bool)) | 145 | void addMapping(void (BufferBuilder::*f)(bool)) |
146 | { | 146 | { |
147 | addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | 147 | addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { |
148 | return [value, f](BufferBuilder &builder) { (builder.*f)(value.value<T>()); }; | 148 | return [value, f](BufferBuilder &builder) { (builder.*f)(value.value<typename T::Type>()); }; |
149 | }); | 149 | }); |
150 | } | 150 | } |
151 | 151 | ||
152 | template <typename T> | 152 | template <typename T> |
153 | void addMapping(const QByteArray &name, void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::String>)) | 153 | void addMapping(void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::String>)) |
154 | { | 154 | { |
155 | addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | 155 | addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { |
156 | auto offset = variantToProperty<T>(value, fbb); | 156 | auto offset = variantToProperty<typename T::Type>(value, fbb); |
157 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; | 157 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; |
158 | }); | 158 | }); |
159 | } | 159 | } |
160 | 160 | ||
161 | template <typename T> | 161 | template <typename T> |
162 | void addMapping(const QByteArray &name, void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<uint8_t>>)) | 162 | void addMapping(void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<uint8_t>>)) |
163 | { | 163 | { |
164 | addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | 164 | addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { |
165 | auto offset = variantToProperty<T>(value, fbb); | 165 | auto offset = variantToProperty<typename T::Type>(value, fbb); |
166 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; | 166 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; |
167 | }); | 167 | }); |
168 | } | 168 | } |
169 | 169 | ||
170 | template <typename T> | 170 | template <typename T> |
171 | void addMapping(const QByteArray &name, void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>)) | 171 | void addMapping(void (BufferBuilder::*f)(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>)) |
172 | { | 172 | { |
173 | addMapping(name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { | 173 | addMapping(T::name, [f](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(BufferBuilder &)> { |
174 | auto offset = variantToProperty<T>(value, fbb); | 174 | auto offset = variantToProperty<typename T::Type>(value, fbb); |
175 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; | 175 | return [offset, f](BufferBuilder &builder) { (builder.*f)(offset); }; |
176 | }); | 176 | }); |
177 | } | 177 | } |
diff --git a/examples/dummyresource/domainadaptor.cpp b/examples/dummyresource/domainadaptor.cpp index 839c4a7..dcc08c7 100644 --- a/examples/dummyresource/domainadaptor.cpp +++ b/examples/dummyresource/domainadaptor.cpp | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "domainadaptor.h" | 20 | #include "domainadaptor.h" |
21 | 21 | ||
22 | #include "dummycalendar_generated.h" | 22 | #include "dummycalendar_generated.h" |
23 | #include "applicationdomaintype.h" | ||
23 | 24 | ||
24 | using namespace DummyCalendar; | 25 | using namespace DummyCalendar; |
25 | using namespace flatbuffers; | 26 | using namespace flatbuffers; |
@@ -28,10 +29,8 @@ DummyEventAdaptorFactory::DummyEventAdaptorFactory() | |||
28 | : DomainTypeAdaptorFactory() | 29 | : DomainTypeAdaptorFactory() |
29 | { | 30 | { |
30 | //TODO turn this into initializeReadPropertyMapper as well? | 31 | //TODO turn this into initializeReadPropertyMapper as well? |
31 | mResourceMapper->addMapping<QString, DummyEvent>("summary", &DummyEvent::summary); | 32 | mResourceMapper->addMapping<Sink::ApplicationDomain::Event::Summary, DummyEvent>(&DummyEvent::summary); |
32 | mResourceMapper->addMapping<QString, DummyEvent>("remoteId", &DummyEvent::remoteId); | 33 | mResourceWriteMapper->addMapping<Sink::ApplicationDomain::Event::Summary>(&DummyEventBuilder::add_summary); |
33 | mResourceWriteMapper->addMapping<QString>("summary", &DummyEventBuilder::add_summary); | ||
34 | mResourceWriteMapper->addMapping<QString>("remoteId", &DummyEventBuilder::add_remoteId); | ||
35 | } | 34 | } |
36 | 35 | ||
37 | DummyMailAdaptorFactory::DummyMailAdaptorFactory() | 36 | DummyMailAdaptorFactory::DummyMailAdaptorFactory() |