From 6b8432a5c0647d8fbe3cda549574ae13e07bb2f4 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 28 Apr 2017 11:48:06 +0200 Subject: Simplified propertymapper --- common/domainadaptor.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'common/domainadaptor.h') diff --git a/common/domainadaptor.h b/common/domainadaptor.h index af5d5fc..9182001 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h @@ -157,8 +157,8 @@ public: LocalBuffer const *mLocalBuffer; ResourceBuffer const *mResourceBuffer; - QSharedPointer> mLocalMapper; - QSharedPointer> mResourceMapper; + QSharedPointer mLocalMapper; + QSharedPointer mResourceMapper; QSharedPointer mIndexMapper; TypeIndex *mIndex; }; @@ -176,8 +176,8 @@ class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInte public: DomainTypeAdaptorFactory() - : mLocalMapper(QSharedPointer>::create()), - mResourceMapper(QSharedPointer>::create()), + : mLocalMapper(QSharedPointer::create()), + mResourceMapper(QSharedPointer::create()), mLocalWriteMapper(QSharedPointer>::create()), mResourceWriteMapper(QSharedPointer>::create()), mIndexMapper(QSharedPointer::create()) @@ -236,8 +236,8 @@ public: protected: - QSharedPointer> mLocalMapper; - QSharedPointer> mResourceMapper; + QSharedPointer mLocalMapper; + QSharedPointer mResourceMapper; QSharedPointer> mLocalWriteMapper; QSharedPointer> mResourceWriteMapper; QSharedPointer mIndexMapper; -- cgit v1.2.3 From a4ce2b2eda8a2fea4263017e6868c327f22f5e47 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 28 Apr 2017 12:19:52 +0200 Subject: Removed the template argument from the write property mapper --- common/domainadaptor.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'common/domainadaptor.h') diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 9182001..2a7924a 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h @@ -40,10 +40,10 @@ */ template flatbuffers::Offset -createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper &mapper) +createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper &mapper) { // First create a primitives such as strings using the mappings - QList> propertiesToAddToResource; + QList> propertiesToAddToResource; for (const auto &property : domainObject.changedProperties()) { // SinkTrace() << "copying property " << property; const auto value = domainObject.getProperty(property); @@ -57,7 +57,7 @@ createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObj // Then create all porperties using the above generated builderCalls Builder builder(fbb); for (auto propertyBuilder : propertiesToAddToResource) { - propertyBuilder(builder); + propertyBuilder(&builder); } return builder.Finish(); } @@ -68,7 +68,7 @@ createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObj * After this the buffer can be extracted from the FlatBufferBuilder object. */ template -static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, WritePropertyMapper &mapper) +static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, WritePropertyMapper &mapper) { auto pos = createBufferPart(domainObject, fbb, mapper); // Because we cannot template the following call @@ -178,8 +178,8 @@ public: DomainTypeAdaptorFactory() : mLocalMapper(QSharedPointer::create()), mResourceMapper(QSharedPointer::create()), - mLocalWriteMapper(QSharedPointer>::create()), - mResourceWriteMapper(QSharedPointer>::create()), + mLocalWriteMapper(QSharedPointer::create()), + mResourceWriteMapper(QSharedPointer::create()), mIndexMapper(QSharedPointer::create()) { Sink::ApplicationDomain::TypeImplementation::configure(*mLocalMapper); @@ -238,8 +238,8 @@ public: protected: QSharedPointer mLocalMapper; QSharedPointer mResourceMapper; - QSharedPointer> mLocalWriteMapper; - QSharedPointer> mResourceWriteMapper; + QSharedPointer mLocalWriteMapper; + QSharedPointer mResourceWriteMapper; QSharedPointer mIndexMapper; }; -- cgit v1.2.3 From 5b408ab7e4a2921aea50153782b126e146faeb53 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 28 Apr 2017 12:23:20 +0200 Subject: Removed more unnecessary template arguments --- common/domainadaptor.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'common/domainadaptor.h') diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 2a7924a..3fbb95f 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h @@ -120,7 +120,6 @@ private: /** * A generic adaptor implementation that uses a property mapper to read/write values. */ -template class DatastoreBufferAdaptor : public Sink::ApplicationDomain::BufferAdaptor { SINK_DEBUG_AREA("bufferadaptor") @@ -155,8 +154,8 @@ public: return mResourceMapper->availableProperties() + mLocalMapper->availableProperties() + mIndexMapper->availableProperties(); } - LocalBuffer const *mLocalBuffer; - ResourceBuffer const *mResourceBuffer; + void const *mLocalBuffer; + void const *mResourceBuffer; QSharedPointer mLocalMapper; QSharedPointer mResourceMapper; QSharedPointer mIndexMapper; @@ -196,7 +195,7 @@ public: */ virtual QSharedPointer createAdaptor(const Sink::Entity &entity, TypeIndex *index = nullptr) Q_DECL_OVERRIDE { - auto adaptor = QSharedPointer>::create(); + auto adaptor = QSharedPointer::create(); adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer(entity.local()); adaptor->mLocalMapper = mLocalMapper; adaptor->mResourceBuffer = Sink::EntityBuffer::readBuffer(entity.resource()); -- cgit v1.2.3 From a08984c450b1cd2584272b0d57a2f95ae3d074c3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 28 Apr 2017 15:25:47 +0200 Subject: Removed the resource mapper --- common/domainadaptor.h | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'common/domainadaptor.h') 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 @@ #include "domain/typeimplementations.h" #include "bufferadaptor.h" #include "entity_generated.h" -#include "metadata_generated.h" #include "entitybuffer.h" #include "propertymapper.h" #include "log.h" -#include "dummy_generated.h" /** * Create a buffer from a domain object using the provided mappings @@ -136,9 +134,7 @@ public: virtual QVariant getProperty(const QByteArray &key) const Q_DECL_OVERRIDE { - if (mResourceBuffer && mResourceMapper->hasMapping(key)) { - return mResourceMapper->getProperty(key, mResourceBuffer); - } else if (mLocalBuffer && mLocalMapper->hasMapping(key)) { + if (mLocalBuffer && mLocalMapper->hasMapping(key)) { return mLocalMapper->getProperty(key, mLocalBuffer); } else if (mIndex && mIndexMapper->hasMapping(key)) { return mIndexMapper->getProperty(key, *mIndex, *this); @@ -151,23 +147,21 @@ public: */ virtual QList availableProperties() const Q_DECL_OVERRIDE { - return mResourceMapper->availableProperties() + mLocalMapper->availableProperties() + mIndexMapper->availableProperties(); + return mLocalMapper->availableProperties() + mIndexMapper->availableProperties(); } void const *mLocalBuffer; - void const *mResourceBuffer; QSharedPointer mLocalMapper; - QSharedPointer mResourceMapper; QSharedPointer mIndexMapper; TypeIndex *mIndex; }; /** - * The factory should define how to go from an entitybuffer (local + resource buffer), to a domain type adapter. + * The factory should define how to go from an entitybuffer (local buffer), to a domain type adapter. * It defines how values are split accross local and resource buffer. * This is required by the facade the read the value, and by the pipeline preprocessors to access the domain values in a generic way. */ -template +template class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface { typedef typename Sink::ApplicationDomain::TypeImplementation::Buffer LocalBuffer; @@ -176,9 +170,7 @@ class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInte public: DomainTypeAdaptorFactory() : mLocalMapper(QSharedPointer::create()), - mResourceMapper(QSharedPointer::create()), mLocalWriteMapper(QSharedPointer::create()), - mResourceWriteMapper(QSharedPointer::create()), mIndexMapper(QSharedPointer::create()) { Sink::ApplicationDomain::TypeImplementation::configure(*mLocalMapper); @@ -189,7 +181,7 @@ public: virtual ~DomainTypeAdaptorFactory(){}; /** - * Creates an adaptor for the given domain and resource types. + * Creates an adaptor for the given domain types. * * This returns by default a DatastoreBufferAdaptor initialized with the corresponding property mappers. */ @@ -198,8 +190,6 @@ public: auto adaptor = QSharedPointer::create(); adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer(entity.local()); adaptor->mLocalMapper = mLocalMapper; - adaptor->mResourceBuffer = Sink::EntityBuffer::readBuffer(entity.resource()); - adaptor->mResourceMapper = mResourceMapper; adaptor->mIndexMapper = mIndexMapper; adaptor->mIndex = index; return adaptor; @@ -214,13 +204,7 @@ public: createBufferPartBuffer(domainObject, localFbb, *mLocalWriteMapper); } - flatbuffers::FlatBufferBuilder resFbb; - if (mResourceWriteMapper) { - // SinkTrace() << "Creating resouce buffer part"; - createBufferPartBuffer(domainObject, resFbb, *mResourceWriteMapper); - } - - Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, resFbb.GetBufferPointer(), resFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); + Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, 0, 0, localFbb.GetBufferPointer(), localFbb.GetSize()); return true; } @@ -236,9 +220,7 @@ public: protected: QSharedPointer mLocalMapper; - QSharedPointer mResourceMapper; QSharedPointer mLocalWriteMapper; - QSharedPointer mResourceWriteMapper; QSharedPointer mIndexMapper; }; -- cgit v1.2.3 From ca5020095abfb76e63bd801e9722c07193eb05f5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 28 Apr 2017 15:29:18 +0200 Subject: A single propertymapper for both directions --- common/domainadaptor.h | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'common/domainadaptor.h') 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 @@ */ template flatbuffers::Offset -createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper &mapper) +createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const PropertyMapper &mapper) { // First create a primitives such as strings using the mappings QList> propertiesToAddToResource; @@ -66,7 +66,7 @@ createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObj * After this the buffer can be extracted from the FlatBufferBuilder object. */ template -static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, WritePropertyMapper &mapper) +static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, PropertyMapper &mapper) { auto pos = createBufferPart(domainObject, fbb, mapper); // Because we cannot template the following call @@ -151,7 +151,7 @@ public: } void const *mLocalBuffer; - QSharedPointer mLocalMapper; + QSharedPointer mLocalMapper; QSharedPointer mIndexMapper; TypeIndex *mIndex; }; @@ -169,12 +169,10 @@ class SINK_EXPORT DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInte public: DomainTypeAdaptorFactory() - : mLocalMapper(QSharedPointer::create()), - mLocalWriteMapper(QSharedPointer::create()), + : mPropertyMapper(QSharedPointer::create()), mIndexMapper(QSharedPointer::create()) { - Sink::ApplicationDomain::TypeImplementation::configure(*mLocalMapper); - Sink::ApplicationDomain::TypeImplementation::configure(*mLocalWriteMapper); + Sink::ApplicationDomain::TypeImplementation::configure(*mPropertyMapper); Sink::ApplicationDomain::TypeImplementation::configure(*mIndexMapper); } @@ -189,7 +187,7 @@ public: { auto adaptor = QSharedPointer::create(); adaptor->mLocalBuffer = Sink::EntityBuffer::readBuffer(entity.local()); - adaptor->mLocalMapper = mLocalMapper; + adaptor->mLocalMapper = mPropertyMapper; adaptor->mIndexMapper = mIndexMapper; adaptor->mIndex = index; return adaptor; @@ -199,11 +197,7 @@ public: createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE { flatbuffers::FlatBufferBuilder localFbb; - if (mLocalWriteMapper) { - // SinkTrace() << "Creating local buffer part"; - createBufferPartBuffer(domainObject, localFbb, *mLocalWriteMapper); - } - + createBufferPartBuffer(domainObject, localFbb, *mPropertyMapper); Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, 0, 0, localFbb.GetBufferPointer(), localFbb.GetSize()); return true; } @@ -219,8 +213,7 @@ public: protected: - QSharedPointer mLocalMapper; - QSharedPointer mLocalWriteMapper; + QSharedPointer mPropertyMapper; QSharedPointer mIndexMapper; }; -- cgit v1.2.3 From 41f8f9bc05c059cafa780ac8aec27a56cba2c278 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 12 May 2017 08:20:43 +0200 Subject: No more SINK_DEBUG_AREA --- common/domainadaptor.h | 1 - 1 file changed, 1 deletion(-) (limited to 'common/domainadaptor.h') diff --git a/common/domainadaptor.h b/common/domainadaptor.h index c38b713..f981a1f 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h @@ -120,7 +120,6 @@ private: */ class DatastoreBufferAdaptor : public Sink::ApplicationDomain::BufferAdaptor { - SINK_DEBUG_AREA("bufferadaptor") public: DatastoreBufferAdaptor() : BufferAdaptor() { -- cgit v1.2.3