summaryrefslogtreecommitdiffstats
path: root/common/entitystore.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/entitystore.h')
-rw-r--r--common/entitystore.h30
1 files changed, 11 insertions, 19 deletions
diff --git a/common/entitystore.h b/common/entitystore.h
index 6bfe414..3d9ca36 100644
--- a/common/entitystore.h
+++ b/common/entitystore.h
@@ -20,50 +20,42 @@
20#pragma once 20#pragma once
21 21
22#include "sink_export.h" 22#include "sink_export.h"
23#include <domainadaptor.h>
24 23
25#include "storage.h" 24#include "storage/entitystore.h"
26#include "adaptorfactoryregistry.h"
27#include "entityreader.h"
28 25
29namespace Sink { 26namespace Sink {
30 27
31class SINK_EXPORT EntityStore 28class SINK_EXPORT EntityStore
32{ 29{
33public: 30public:
34 EntityStore(const QByteArray &resourceType, const QByteArray &mResourceInstanceIdentifier, Sink::Storage::Transaction &transaction); 31 EntityStore(Storage::EntityStore &store);
35 32
36 template<typename T> 33 template<typename T>
37 T read(const QByteArray &identifier) const 34 T read(const QByteArray &identifier) const
38 { 35 {
39 EntityReader<T> reader(mResourceType, mResourceInstanceIdentifier, mTransaction); 36 return store.readLatest<T>(identifier);
40 return reader.read(identifier);
41 } 37 }
42 38
43 template<typename T> 39 template<typename T>
44 T readFromKey(const QByteArray &key) const 40 T readFromKey(const QByteArray &key) const
45 { 41 {
46 EntityReader<T> reader(mResourceType, mResourceInstanceIdentifier, mTransaction); 42 return store.readEntity<T>(key);
47 return reader.readFromKey(key);
48 } 43 }
49 44
50 template<typename T> 45 template<typename T>
51 T readPrevious(const QByteArray &uid, qint64 revision) const 46 T readPrevious(const QByteArray &uid, qint64 revision) const
52 { 47 {
53 EntityReader<T> reader(mResourceType, mResourceInstanceIdentifier, mTransaction); 48 return store.readPrevious<T>(uid, revision);
54 return reader.readPrevious(uid, revision);
55 } 49 }
56 50
57 template<typename T> 51 /* template<typename T> */
58 EntityReader<T> reader() 52 /* EntityReader<T> reader() */
59 { 53 /* { */
60 return EntityReader<T>(mResourceType, mResourceInstanceIdentifier, mTransaction); 54 /* return EntityReader<T>(mResourceType, mResourceInstanceIdentifier, mTransaction); */
61 } 55 /* } */
62 56
63private: 57private:
64 QByteArray mResourceType; 58 Sink::Storage::EntityStore &store;
65 QByteArray mResourceInstanceIdentifier;
66 Sink::Storage::Transaction &mTransaction;
67}; 59};
68 60
69} 61}