summaryrefslogtreecommitdiffstats
path: root/common/entitystore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/entitystore.cpp')
-rw-r--r--common/entitystore.cpp16
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
49QSharedPointer<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 [&current, &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}