diff options
Diffstat (limited to 'common/entitystore.h')
-rw-r--r-- | common/entitystore.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/common/entitystore.h b/common/entitystore.h index b6f8713..24f43b1 100644 --- a/common/entitystore.h +++ b/common/entitystore.h | |||
@@ -37,11 +37,12 @@ public: | |||
37 | { | 37 | { |
38 | auto typeName = ApplicationDomain::getTypeName<T>(); | 38 | auto typeName = ApplicationDomain::getTypeName<T>(); |
39 | auto mainDatabase = Storage::mainDatabase(mTransaction, typeName); | 39 | auto mainDatabase = Storage::mainDatabase(mTransaction, typeName); |
40 | auto bufferAdaptor = getLatest(mainDatabase, identifier, *Sink::AdaptorFactoryRegistry::instance().getFactory<T>(mResourceType)); | 40 | qint64 retrievedRevision = 0; |
41 | auto bufferAdaptor = getLatest(mainDatabase, identifier, *Sink::AdaptorFactoryRegistry::instance().getFactory<T>(mResourceType), retrievedRevision); | ||
41 | if (!bufferAdaptor) { | 42 | if (!bufferAdaptor) { |
42 | return T(); | 43 | return T(); |
43 | } | 44 | } |
44 | return T(mResourceInstanceIdentifier, identifier, 0, bufferAdaptor); | 45 | return T(mResourceInstanceIdentifier, identifier, retrievedRevision, bufferAdaptor); |
45 | } | 46 | } |
46 | 47 | ||
47 | template<typename T> | 48 | template<typename T> |
@@ -49,17 +50,33 @@ public: | |||
49 | { | 50 | { |
50 | auto typeName = ApplicationDomain::getTypeName<T>(); | 51 | auto typeName = ApplicationDomain::getTypeName<T>(); |
51 | auto mainDatabase = Storage::mainDatabase(mTransaction, typeName); | 52 | auto mainDatabase = Storage::mainDatabase(mTransaction, typeName); |
52 | auto bufferAdaptor = get(mainDatabase, key, *Sink::AdaptorFactoryRegistry::instance().getFactory<T>(mResourceType)); | 53 | qint64 retrievedRevision = 0; |
54 | auto bufferAdaptor = get(mainDatabase, key, *Sink::AdaptorFactoryRegistry::instance().getFactory<T>(mResourceType), retrievedRevision); | ||
53 | const auto identifier = Storage::uidFromKey(key); | 55 | const auto identifier = Storage::uidFromKey(key); |
54 | if (!bufferAdaptor) { | 56 | if (!bufferAdaptor) { |
55 | return T(); | 57 | return T(); |
56 | } | 58 | } |
57 | return T(mResourceInstanceIdentifier, identifier, 0, bufferAdaptor); | 59 | return T(mResourceInstanceIdentifier, identifier, retrievedRevision, bufferAdaptor); |
58 | } | 60 | } |
59 | 61 | ||
62 | template<typename T> | ||
63 | T readPrevious(const QByteArray &uid, qint64 revision) const | ||
64 | { | ||
65 | auto typeName = ApplicationDomain::getTypeName<T>(); | ||
66 | auto mainDatabase = Storage::mainDatabase(mTransaction, typeName); | ||
67 | qint64 retrievedRevision = 0; | ||
68 | auto bufferAdaptor = getPrevious(mainDatabase, uid, revision, *Sink::AdaptorFactoryRegistry::instance().getFactory<T>(mResourceType), retrievedRevision); | ||
69 | if (!bufferAdaptor) { | ||
70 | return T(); | ||
71 | } | ||
72 | return T(mResourceInstanceIdentifier, uid, retrievedRevision, bufferAdaptor); | ||
73 | } | ||
74 | |||
75 | |||
60 | 76 | ||
61 | static QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> getLatest(const Sink::Storage::NamedDatabase &db, const QByteArray &uid, DomainTypeAdaptorFactoryInterface &adaptorFactory); | 77 | static QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> getLatest(const Sink::Storage::NamedDatabase &db, const QByteArray &uid, DomainTypeAdaptorFactoryInterface &adaptorFactory, qint64 &retrievedRevision); |
62 | static QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> get(const Sink::Storage::NamedDatabase &db, const QByteArray &key, DomainTypeAdaptorFactoryInterface &adaptorFactory); | 78 | static QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> get(const Sink::Storage::NamedDatabase &db, const QByteArray &key, DomainTypeAdaptorFactoryInterface &adaptorFactory, qint64 &retrievedRevision); |
79 | static QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> getPrevious(const Sink::Storage::NamedDatabase &db, const QByteArray &uid, qint64 revision, DomainTypeAdaptorFactoryInterface &adaptorFactory, qint64 &retrievedRevision); | ||
63 | private: | 80 | private: |
64 | QByteArray mResourceType; | 81 | QByteArray mResourceType; |
65 | QByteArray mResourceInstanceIdentifier; | 82 | QByteArray mResourceInstanceIdentifier; |