diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-28 15:29:18 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-28 15:30:15 +0200 |
commit | ca5020095abfb76e63bd801e9722c07193eb05f5 (patch) | |
tree | 34d6344e982adcea4652a3ccb6bfb43b118a5189 /common/domainadaptor.h | |
parent | a08984c450b1cd2584272b0d57a2f95ae3d074c3 (diff) | |
download | sink-ca5020095abfb76e63bd801e9722c07193eb05f5.tar.gz sink-ca5020095abfb76e63bd801e9722c07193eb05f5.zip |
A single propertymapper for both directions
Diffstat (limited to 'common/domainadaptor.h')
-rw-r--r-- | common/domainadaptor.h | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 1db43ca..c38b713 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h | |||
@@ -38,7 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | template <class Builder, class Buffer> | 39 | template <class Builder, class Buffer> |
40 | flatbuffers::Offset<Buffer> | 40 | flatbuffers::Offset<Buffer> |
41 | createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper &mapper) | 41 | createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const PropertyMapper &mapper) |
42 | { | 42 | { |
43 | // First create a primitives such as strings using the mappings | 43 | // First create a primitives such as strings using the mappings |
44 | QList<std::function<void(void *builder)>> propertiesToAddToResource; | 44 | QList<std::function<void(void *builder)>> propertiesToAddToResource; |
@@ -66,7 +66,7 @@ createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObj | |||
66 | * After this the buffer can be extracted from the FlatBufferBuilder object. | 66 | * After this the buffer can be extracted from the FlatBufferBuilder object. |
67 | */ | 67 | */ |
68 | template <typename Buffer, typename BufferBuilder> | 68 | template <typename Buffer, typename BufferBuilder> |
69 | static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, WritePropertyMapper &mapper) | 69 | static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, PropertyMapper &mapper) |
70 | { | 70 | { |
71 | auto pos = createBufferPart<BufferBuilder, Buffer>(domainObject, fbb, mapper); | 71 | auto pos = createBufferPart<BufferBuilder, Buffer>(domainObject, fbb, mapper); |
72 | // Because we cannot template the following call | 72 | // Because we cannot template the following call |
@@ -151,7 +151,7 @@ public: | |||
151 | } | 151 | } |
152 | 152 | ||
153 | void const *mLocalBuffer; | 153 | void const *mLocalBuffer; |
154 | QSharedPointer<ReadPropertyMapper> mLocalMapper; | 154 | QSharedPointer<PropertyMapper> mLocalMapper; |
155 | QSharedPointer<IndexPropertyMapper> mIndexMapper; | 155 | QSharedPointer<IndexPropertyMapper> mIndexMapper; |
156 | TypeIndex *mIndex; | 156 | TypeIndex *mIndex; |
157 | }; | 157 | }; |
@@ -169,12 +169,10 @@ class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInte | |||
169 | 169 | ||
170 | public: | 170 | public: |
171 | DomainTypeAdaptorFactory() | 171 | DomainTypeAdaptorFactory() |
172 | : mLocalMapper(QSharedPointer<ReadPropertyMapper>::create()), | 172 | : mPropertyMapper(QSharedPointer<PropertyMapper>::create()), |
173 | mLocalWriteMapper(QSharedPointer<WritePropertyMapper>::create()), | ||
174 | mIndexMapper(QSharedPointer<IndexPropertyMapper>::create()) | 173 | mIndexMapper(QSharedPointer<IndexPropertyMapper>::create()) |
175 | { | 174 | { |
176 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mLocalMapper); | 175 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mPropertyMapper); |
177 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mLocalWriteMapper); | ||
178 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mIndexMapper); | 176 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mIndexMapper); |
179 | } | 177 | } |
180 | 178 | ||
@@ -189,7 +187,7 @@ public: | |||
189 | { | 187 | { |
190 | auto adaptor = QSharedPointer<DatastoreBufferAdaptor>::create(); | 188 | auto adaptor = QSharedPointer<DatastoreBufferAdaptor>::create(); |
191 | adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); | 189 | adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); |
192 | adaptor->mLocalMapper = mLocalMapper; | 190 | adaptor->mLocalMapper = mPropertyMapper; |
193 | adaptor->mIndexMapper = mIndexMapper; | 191 | adaptor->mIndexMapper = mIndexMapper; |
194 | adaptor->mIndex = index; | 192 | adaptor->mIndex = index; |
195 | return adaptor; | 193 | return adaptor; |
@@ -199,11 +197,7 @@ public: | |||
199 | createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE | 197 | createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE |
200 | { | 198 | { |
201 | flatbuffers::FlatBufferBuilder localFbb; | 199 | flatbuffers::FlatBufferBuilder localFbb; |
202 | if (mLocalWriteMapper) { | 200 | createBufferPartBuffer<LocalBuffer, LocalBuilder>(domainObject, localFbb, *mPropertyMapper); |
203 | // SinkTrace() << "Creating local buffer part"; | ||
204 | createBufferPartBuffer<LocalBuffer, LocalBuilder>(domainObject, localFbb, *mLocalWriteMapper); | ||
205 | } | ||
206 | |||
207 | Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, 0, 0, localFbb.GetBufferPointer(), localFbb.GetSize()); | 201 | Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, 0, 0, localFbb.GetBufferPointer(), localFbb.GetSize()); |
208 | return true; | 202 | return true; |
209 | } | 203 | } |
@@ -219,8 +213,7 @@ public: | |||
219 | 213 | ||
220 | 214 | ||
221 | protected: | 215 | protected: |
222 | QSharedPointer<ReadPropertyMapper> mLocalMapper; | 216 | QSharedPointer<PropertyMapper> mPropertyMapper; |
223 | QSharedPointer<WritePropertyMapper> mLocalWriteMapper; | ||
224 | QSharedPointer<IndexPropertyMapper> mIndexMapper; | 217 | QSharedPointer<IndexPropertyMapper> mIndexMapper; |
225 | }; | 218 | }; |
226 | 219 | ||