diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-12 16:02:10 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-12 16:02:10 +0200 |
commit | e85967518b9041e9943ec5f1765c6694bb153840 (patch) | |
tree | 0f4c8a87a0788c67fbe7c11414c0d96a7f863d11 /common/domainadaptor.cpp | |
parent | ea348c62fdebe1d9c6531fc4491d3316a1e941df (diff) | |
download | sink-e85967518b9041e9943ec5f1765c6694bb153840.tar.gz sink-e85967518b9041e9943ec5f1765c6694bb153840.zip |
More generic domainadpator code.
This should cover read and write for entites that have a 1:1 mapping to the
resource buffers.
Diffstat (limited to 'common/domainadaptor.cpp')
-rw-r--r-- | common/domainadaptor.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/common/domainadaptor.cpp b/common/domainadaptor.cpp index 5e6f062..aa8c3d9 100644 --- a/common/domainadaptor.cpp +++ b/common/domainadaptor.cpp | |||
@@ -20,6 +20,15 @@ | |||
20 | #include "domainadaptor.h" | 20 | #include "domainadaptor.h" |
21 | 21 | ||
22 | template <> | 22 | template <> |
23 | flatbuffers::uoffset_t extractProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
24 | { | ||
25 | if (property.isValid()) { | ||
26 | return fbb.CreateString(property.toString().toStdString()).o; | ||
27 | } | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | template <> | ||
23 | QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > initializeReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event>() | 32 | QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > initializeReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event>() |
24 | { | 33 | { |
25 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >::create(); | 34 | auto propertyMapper = QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> >::create(); |
@@ -38,3 +47,17 @@ QSharedPointer<ReadPropertyMapper<Akonadi2::ApplicationDomain::Buffer::Event> > | |||
38 | return propertyMapper; | 47 | return propertyMapper; |
39 | } | 48 | } |
40 | 49 | ||
50 | template <> | ||
51 | QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> > initializeWritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder>() | ||
52 | { | ||
53 | auto propertyMapper = QSharedPointer<WritePropertyMapper<Akonadi2::ApplicationDomain::Buffer::EventBuilder> >::create(); | ||
54 | propertyMapper->addMapping("summary", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Akonadi2::ApplicationDomain::Buffer::EventBuilder &)> { | ||
55 | auto offset = extractProperty<QString>(value, fbb); | ||
56 | return [offset](Akonadi2::ApplicationDomain::Buffer::EventBuilder &builder) { builder.add_summary(offset); }; | ||
57 | }); | ||
58 | propertyMapper->addMapping("uid", [](const QVariant &value, flatbuffers::FlatBufferBuilder &fbb) -> std::function<void(Akonadi2::ApplicationDomain::Buffer::EventBuilder &)> { | ||
59 | auto offset = extractProperty<QString>(value, fbb); | ||
60 | return [offset](Akonadi2::ApplicationDomain::Buffer::EventBuilder &builder) { builder.add_uid(offset); }; | ||
61 | }); | ||
62 | return propertyMapper; | ||
63 | } | ||