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 ++++++------------------------ examples/dummyresource/domainadaptor.cpp | 3 --- examples/dummyresource/domainadaptor.h | 8 +++----- tests/domainadaptortest.cpp | 8 ++------ tests/testimplementations.h | 4 ++-- 5 files changed, 13 insertions(+), 40 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 @@ #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; }; diff --git a/examples/dummyresource/domainadaptor.cpp b/examples/dummyresource/domainadaptor.cpp index dcc08c7..e7a20da 100644 --- a/examples/dummyresource/domainadaptor.cpp +++ b/examples/dummyresource/domainadaptor.cpp @@ -28,9 +28,6 @@ using namespace flatbuffers; DummyEventAdaptorFactory::DummyEventAdaptorFactory() : DomainTypeAdaptorFactory() { - //TODO turn this into initializeReadPropertyMapper as well? - mResourceMapper->addMapping(&DummyEvent::summary); - mResourceWriteMapper->addMapping(&DummyEventBuilder::add_summary); } DummyMailAdaptorFactory::DummyMailAdaptorFactory() diff --git a/examples/dummyresource/domainadaptor.h b/examples/dummyresource/domainadaptor.h index e7098e9..3faaa63 100644 --- a/examples/dummyresource/domainadaptor.h +++ b/examples/dummyresource/domainadaptor.h @@ -22,25 +22,23 @@ #include "event_generated.h" #include "mail_generated.h" #include "folder_generated.h" -#include "dummy_generated.h" -#include "dummycalendar_generated.h" #include "entity_generated.h" -class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory +class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory { public: DummyEventAdaptorFactory(); virtual ~DummyEventAdaptorFactory() {}; }; -class DummyMailAdaptorFactory : public DomainTypeAdaptorFactory +class DummyMailAdaptorFactory : public DomainTypeAdaptorFactory { public: DummyMailAdaptorFactory(); virtual ~DummyMailAdaptorFactory() {}; }; -class DummyFolderAdaptorFactory : public DomainTypeAdaptorFactory +class DummyFolderAdaptorFactory : public DomainTypeAdaptorFactory { public: DummyFolderAdaptorFactory(); diff --git a/tests/domainadaptortest.cpp b/tests/domainadaptortest.cpp index c5f6e3b..2b7455a 100644 --- a/tests/domainadaptortest.cpp +++ b/tests/domainadaptortest.cpp @@ -14,23 +14,19 @@ #include "metadata_generated.h" #include "entity_generated.h" -class TestFactory : public DomainTypeAdaptorFactory +class TestFactory : public DomainTypeAdaptorFactory { public: TestFactory() { - mResourceWriteMapper = QSharedPointer::create(); - Sink::ApplicationDomain::TypeImplementation::configure(*mResourceWriteMapper); } }; -class TestMailFactory : public DomainTypeAdaptorFactory +class TestMailFactory : public DomainTypeAdaptorFactory { public: TestMailFactory() { - mResourceWriteMapper = QSharedPointer::create(); - Sink::ApplicationDomain::TypeImplementation::configure(*mResourceWriteMapper); } }; diff --git a/tests/testimplementations.h b/tests/testimplementations.h index a145265..ff9d9b8 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h @@ -33,7 +33,7 @@ #include "mail_generated.h" #include "createentity_generated.h" -class TestEventAdaptorFactory : public DomainTypeAdaptorFactory +class TestEventAdaptorFactory : public DomainTypeAdaptorFactory { public: TestEventAdaptorFactory() : DomainTypeAdaptorFactory() @@ -43,7 +43,7 @@ public: virtual ~TestEventAdaptorFactory(){}; }; -class TestMailAdaptorFactory : public DomainTypeAdaptorFactory +class TestMailAdaptorFactory : public DomainTypeAdaptorFactory { public: TestMailAdaptorFactory() : DomainTypeAdaptorFactory() -- cgit v1.2.3