diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-02 13:32:51 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-02 13:32:51 +0200 |
commit | c950e43e8f06324c6ba95dffe59ca0e6d6b840a8 (patch) | |
tree | f64f27a9e9a8e5a762bbf64a1029ea3c1a8fe85a /common/entitystore.cpp | |
parent | c8587bca69546a3a5fd1b2f6c09aff89095a90f8 (diff) | |
download | sink-c950e43e8f06324c6ba95dffe59ca0e6d6b840a8.tar.gz sink-c950e43e8f06324c6ba95dffe59ca0e6d6b840a8.zip |
Reading of individual revisions from the store
Diffstat (limited to 'common/entitystore.cpp')
-rw-r--r-- | common/entitystore.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/common/entitystore.cpp b/common/entitystore.cpp index 2c15abf..5f44609 100644 --- a/common/entitystore.cpp +++ b/common/entitystore.cpp | |||
@@ -46,3 +46,19 @@ QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> EntityStore::getLatest(co | |||
46 | return current; | 46 | return current; |
47 | } | 47 | } |
48 | 48 | ||
49 | QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> EntityStore::get(const Sink::Storage::NamedDatabase &db, const QByteArray &key, DomainTypeAdaptorFactoryInterface &adaptorFactory) | ||
50 | { | ||
51 | QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> current; | ||
52 | db.scan(key, | ||
53 | [¤t, &adaptorFactory](const QByteArray &key, const QByteArray &data) -> bool { | ||
54 | Sink::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | ||
55 | if (!buffer.isValid()) { | ||
56 | Warning() << "Read invalid buffer from disk"; | ||
57 | } else { | ||
58 | current = adaptorFactory.createAdaptor(buffer.entity()); | ||
59 | } | ||
60 | return false; | ||
61 | }, | ||
62 | [](const Sink::Storage::Error &error) { Warning() << "Failed to read current value from storage: " << error.message; }); | ||
63 | return current; | ||
64 | } | ||