diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-28 15:25:47 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-28 15:30:15 +0200 |
commit | a08984c450b1cd2584272b0d57a2f95ae3d074c3 (patch) | |
tree | 6690a66668ea32c3c9666d36e5f9134c021d68ce /common/domainadaptor.h | |
parent | 5b408ab7e4a2921aea50153782b126e146faeb53 (diff) | |
download | sink-a08984c450b1cd2584272b0d57a2f95ae3d074c3.tar.gz sink-a08984c450b1cd2584272b0d57a2f95ae3d074c3.zip |
Removed the resource mapper
Diffstat (limited to 'common/domainadaptor.h')
-rw-r--r-- | common/domainadaptor.h | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 3fbb95f..1db43ca 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h | |||
@@ -29,11 +29,9 @@ | |||
29 | #include "domain/typeimplementations.h" | 29 | #include "domain/typeimplementations.h" |
30 | #include "bufferadaptor.h" | 30 | #include "bufferadaptor.h" |
31 | #include "entity_generated.h" | 31 | #include "entity_generated.h" |
32 | #include "metadata_generated.h" | ||
33 | #include "entitybuffer.h" | 32 | #include "entitybuffer.h" |
34 | #include "propertymapper.h" | 33 | #include "propertymapper.h" |
35 | #include "log.h" | 34 | #include "log.h" |
36 | #include "dummy_generated.h" | ||
37 | 35 | ||
38 | /** | 36 | /** |
39 | * Create a buffer from a domain object using the provided mappings | 37 | * Create a buffer from a domain object using the provided mappings |
@@ -136,9 +134,7 @@ public: | |||
136 | 134 | ||
137 | virtual QVariant getProperty(const QByteArray &key) const Q_DECL_OVERRIDE | 135 | virtual QVariant getProperty(const QByteArray &key) const Q_DECL_OVERRIDE |
138 | { | 136 | { |
139 | if (mResourceBuffer && mResourceMapper->hasMapping(key)) { | 137 | if (mLocalBuffer && mLocalMapper->hasMapping(key)) { |
140 | return mResourceMapper->getProperty(key, mResourceBuffer); | ||
141 | } else if (mLocalBuffer && mLocalMapper->hasMapping(key)) { | ||
142 | return mLocalMapper->getProperty(key, mLocalBuffer); | 138 | return mLocalMapper->getProperty(key, mLocalBuffer); |
143 | } else if (mIndex && mIndexMapper->hasMapping(key)) { | 139 | } else if (mIndex && mIndexMapper->hasMapping(key)) { |
144 | return mIndexMapper->getProperty(key, *mIndex, *this); | 140 | return mIndexMapper->getProperty(key, *mIndex, *this); |
@@ -151,23 +147,21 @@ public: | |||
151 | */ | 147 | */ |
152 | virtual QList<QByteArray> availableProperties() const Q_DECL_OVERRIDE | 148 | virtual QList<QByteArray> availableProperties() const Q_DECL_OVERRIDE |
153 | { | 149 | { |
154 | return mResourceMapper->availableProperties() + mLocalMapper->availableProperties() + mIndexMapper->availableProperties(); | 150 | return mLocalMapper->availableProperties() + mIndexMapper->availableProperties(); |
155 | } | 151 | } |
156 | 152 | ||
157 | void const *mLocalBuffer; | 153 | void const *mLocalBuffer; |
158 | void const *mResourceBuffer; | ||
159 | QSharedPointer<ReadPropertyMapper> mLocalMapper; | 154 | QSharedPointer<ReadPropertyMapper> mLocalMapper; |
160 | QSharedPointer<ReadPropertyMapper> mResourceMapper; | ||
161 | QSharedPointer<IndexPropertyMapper> mIndexMapper; | 155 | QSharedPointer<IndexPropertyMapper> mIndexMapper; |
162 | TypeIndex *mIndex; | 156 | TypeIndex *mIndex; |
163 | }; | 157 | }; |
164 | 158 | ||
165 | /** | 159 | /** |
166 | * The factory should define how to go from an entitybuffer (local + resource buffer), to a domain type adapter. | 160 | * The factory should define how to go from an entitybuffer (local buffer), to a domain type adapter. |
167 | * It defines how values are split accross local and resource buffer. | 161 | * It defines how values are split accross local and resource buffer. |
168 | * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. | 162 | * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. |
169 | */ | 163 | */ |
170 | template <typename DomainType, typename ResourceBuffer = Sink::ApplicationDomain::Buffer::Dummy, typename ResourceBuilder = Sink::ApplicationDomain::Buffer::DummyBuilder> | 164 | template <typename DomainType> |
171 | class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface | 165 | class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface |
172 | { | 166 | { |
173 | typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; | 167 | typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; |
@@ -176,9 +170,7 @@ class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInte | |||
176 | public: | 170 | public: |
177 | DomainTypeAdaptorFactory() | 171 | DomainTypeAdaptorFactory() |
178 | : mLocalMapper(QSharedPointer<ReadPropertyMapper>::create()), | 172 | : mLocalMapper(QSharedPointer<ReadPropertyMapper>::create()), |
179 | mResourceMapper(QSharedPointer<ReadPropertyMapper>::create()), | ||
180 | mLocalWriteMapper(QSharedPointer<WritePropertyMapper>::create()), | 173 | mLocalWriteMapper(QSharedPointer<WritePropertyMapper>::create()), |
181 | mResourceWriteMapper(QSharedPointer<WritePropertyMapper>::create()), | ||
182 | mIndexMapper(QSharedPointer<IndexPropertyMapper>::create()) | 174 | mIndexMapper(QSharedPointer<IndexPropertyMapper>::create()) |
183 | { | 175 | { |
184 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mLocalMapper); | 176 | Sink::ApplicationDomain::TypeImplementation<DomainType>::configure(*mLocalMapper); |
@@ -189,7 +181,7 @@ public: | |||
189 | virtual ~DomainTypeAdaptorFactory(){}; | 181 | virtual ~DomainTypeAdaptorFactory(){}; |
190 | 182 | ||
191 | /** | 183 | /** |
192 | * Creates an adaptor for the given domain and resource types. | 184 | * Creates an adaptor for the given domain types. |
193 | * | 185 | * |
194 | * This returns by default a DatastoreBufferAdaptor initialized with the corresponding property mappers. | 186 | * This returns by default a DatastoreBufferAdaptor initialized with the corresponding property mappers. |
195 | */ | 187 | */ |
@@ -198,8 +190,6 @@ public: | |||
198 | auto adaptor = QSharedPointer<DatastoreBufferAdaptor>::create(); | 190 | auto adaptor = QSharedPointer<DatastoreBufferAdaptor>::create(); |
199 | adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); | 191 | adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); |
200 | adaptor->mLocalMapper = mLocalMapper; | 192 | adaptor->mLocalMapper = mLocalMapper; |
201 | adaptor->mResourceBuffer = Sink::EntityBuffer::readBuffer<ResourceBuffer>(entity.resource()); | ||
202 | adaptor->mResourceMapper = mResourceMapper; | ||
203 | adaptor->mIndexMapper = mIndexMapper; | 193 | adaptor->mIndexMapper = mIndexMapper; |
204 | adaptor->mIndex = index; | 194 | adaptor->mIndex = index; |
205 | return adaptor; | 195 | return adaptor; |
@@ -214,13 +204,7 @@ public: | |||
214 | createBufferPartBuffer<LocalBuffer, LocalBuilder>(domainObject, localFbb, *mLocalWriteMapper); | 204 | createBufferPartBuffer<LocalBuffer, LocalBuilder>(domainObject, localFbb, *mLocalWriteMapper); |
215 | } | 205 | } |
216 | 206 | ||
217 | flatbuffers::FlatBufferBuilder resFbb; | 207 | Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, 0, 0, localFbb.GetBufferPointer(), localFbb.GetSize()); |
218 | if (mResourceWriteMapper) { | ||
219 | // SinkTrace() << "Creating resouce buffer part"; | ||
220 | createBufferPartBuffer<ResourceBuffer, ResourceBuilder>(domainObject, resFbb, *mResourceWriteMapper); | ||
221 | } | ||
222 | |||
223 | Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, resFbb.GetBufferPointer(), resFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | ||
224 | return true; | 208 | return true; |
225 | } | 209 | } |
226 | 210 | ||
@@ -236,9 +220,7 @@ public: | |||
236 | 220 | ||
237 | protected: | 221 | protected: |
238 | QSharedPointer<ReadPropertyMapper> mLocalMapper; | 222 | QSharedPointer<ReadPropertyMapper> mLocalMapper; |
239 | QSharedPointer<ReadPropertyMapper> mResourceMapper; | ||
240 | QSharedPointer<WritePropertyMapper> mLocalWriteMapper; | 223 | QSharedPointer<WritePropertyMapper> mLocalWriteMapper; |
241 | QSharedPointer<WritePropertyMapper> mResourceWriteMapper; | ||
242 | QSharedPointer<IndexPropertyMapper> mIndexMapper; | 224 | QSharedPointer<IndexPropertyMapper> mIndexMapper; |
243 | }; | 225 | }; |
244 | 226 | ||