From 71a0167e0216f84588b492c84e92667847fbe5a5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 18 Oct 2016 12:44:12 +0200 Subject: Use the ApplicationDomainType in the queries as well. We have to access properties, so we need the mapper anyways, and the ApplicationDomainType type shouldn't be a large overhead anyways. --- common/storage/entitystore.cpp | 9 +++++++++ common/storage/entitystore.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'common/storage') diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 9615eca..fe63f0b 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -184,6 +184,15 @@ void EntityStore::readLatest(const QByteArray &type, const QByteArray &uid, cons }); } +void EntityStore::readLatest(const QByteArray &type, const QByteArray &uid, const std::function callback) +{ + readLatest(type, uid, [&](const QByteArray &uid, const EntityBuffer &buffer) { + auto adaptor = d->resourceContext.adaptorFactory(type).createAdaptor(buffer.entity()); + //TODO cache max revision for the duration of the transaction. + callback(ApplicationDomain::ApplicationDomainType{d->resourceContext.instanceId(), uid, DataStore::maxRevision(d->getTransaction()), adaptor}, buffer.operation()); + }); +} + ApplicationDomain::ApplicationDomainType EntityStore::readLatest(const QByteArray &type, const QByteArray &uid) { ApplicationDomain::ApplicationDomainType dt; diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index de29e87..455e9c3 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h @@ -26,6 +26,7 @@ #include "query.h" #include "storage.h" #include "resourcecontext.h" +#include "metadata_generated.h" namespace Sink { class EntityBuffer; @@ -56,6 +57,7 @@ public: void readLatest(const QByteArray &type, const QByteArray &uid, const std::function callback); void readLatest(const QByteArray &type, const QByteArray &uid, const std::function callback); + void readLatest(const QByteArray &type, const QByteArray &uid, const std::function callback); ApplicationDomain::ApplicationDomainType readLatest(const QByteArray &type, const QByteArray &uid); -- cgit v1.2.3