Changeset View
Changeset View
Standalone View
Standalone View
common/storage/entitystore.h
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 38 | public: | |||
---|---|---|---|---|---|
54 | 54 | | |||
55 | void startTransaction(Sink::Storage::DataStore::AccessMode); | 55 | void startTransaction(Sink::Storage::DataStore::AccessMode); | ||
56 | void commitTransaction(); | 56 | void commitTransaction(); | ||
57 | void abortTransaction(); | 57 | void abortTransaction(); | ||
58 | bool hasTransaction() const; | 58 | bool hasTransaction() const; | ||
59 | 59 | | |||
60 | QVector<QByteArray> fullScan(const QByteArray &type); | 60 | QVector<QByteArray> fullScan(const QByteArray &type); | ||
61 | QVector<QByteArray> indexLookup(const QByteArray &type, const QueryBase &query, QSet<QByteArrayList> &appliedFilters, QByteArray &appliedSorting); | 61 | QVector<QByteArray> indexLookup(const QByteArray &type, const QueryBase &query, QSet<QByteArrayList> &appliedFilters, QByteArray &appliedSorting); | ||
62 | QVector<QByteArray> indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value); | 62 | QVector<Sink::Storage::Identifier> indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value); | ||
63 | void indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value, const std::function<void(const QByteArray &uid)> &callback); | 63 | void indexLookup(const QByteArray &type, const QByteArray &property, const QVariant &value, const std::function<void(const QByteArray &uid)> &callback); | ||
64 | template<typename EntityType, typename PropertyType> | 64 | template<typename EntityType, typename PropertyType> | ||
65 | void indexLookup(const QVariant &value, const std::function<void(const QByteArray &uid)> &callback) { | 65 | void indexLookup(const QVariant &value, const std::function<void(const QByteArray &uid)> &callback) { | ||
66 | return indexLookup(ApplicationDomain::getTypeName<EntityType>(), PropertyType::name, value, callback); | 66 | return indexLookup(ApplicationDomain::getTypeName<EntityType>(), PropertyType::name, value, callback); | ||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | ///Returns the uid and buffer. Note that the memory only remains valid until the next operation or transaction end. | 69 | ///Returns the uid and buffer. Note that the memory only remains valid until the next operation or transaction end. | ||
70 | void readLatest(const QByteArray &type, const Identifier &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | ||||
70 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | 71 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | ||
71 | ///Returns an entity. Note that the memory only remains valid until the next operation or transaction end. | 72 | ///Returns an entity. Note that the memory only remains valid until the next operation or transaction end. | ||
73 | void readLatest(const QByteArray &type, const Identifier &uid, const std::function<void(const ApplicationDomainType &entity)> callback); | ||||
72 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomainType &entity)> callback); | 74 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomainType &entity)> callback); | ||
73 | ///Returns an entity and operation. Note that the memory only remains valid until the next operation or transaction end. | 75 | ///Returns an entity and operation. Note that the memory only remains valid until the next operation or transaction end. | ||
76 | void readLatest(const QByteArray &type, const Identifier &uid, const std::function<void(const ApplicationDomainType &entity, Sink::Operation)> callback); | ||||
74 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomainType &entity, Sink::Operation)> callback); | 77 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomainType &entity, Sink::Operation)> callback); | ||
75 | 78 | | |||
76 | ///Returns a copy | 79 | ///Returns a copy | ||
77 | ApplicationDomainType readLatest(const QByteArray &type, const QByteArray &uid); | 80 | ApplicationDomainType readLatest(const QByteArray &type, const QByteArray &uid); | ||
78 | 81 | | |||
79 | template<typename T> | 82 | template<typename T> | ||
80 | T readLatest(const QByteArray &uid) { | 83 | T readLatest(const QByteArray &uid) { | ||
81 | return T(readLatest(ApplicationDomain::getTypeName<T>(), uid)); | 84 | return T(readLatest(ApplicationDomain::getTypeName<T>(), uid)); | ||
82 | } | 85 | } | ||
83 | 86 | | |||
84 | ///Returns the uid and buffer. Note that the memory only remains valid until the next operation or transaction end. | 87 | ///Returns the uid and buffer. Note that the memory only remains valid until the next operation or transaction end. | ||
85 | void readEntity(const QByteArray &type, const QByteArray &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | 88 | void readEntity(const QByteArray &type, const QByteArray &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | ||
86 | ///Returns an entity. Note that the memory only remains valid until the next operation or transaction end. | 89 | ///Returns an entity. Note that the memory only remains valid until the next operation or transaction end. | ||
87 | void readEntity(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomainType &entity)> callback); | 90 | void readEntity(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomainType &entity)> callback); | ||
88 | ///Returns a copy | 91 | ///Returns a copy | ||
89 | ApplicationDomainType readEntity(const QByteArray &type, const QByteArray &key); | 92 | ApplicationDomainType readEntity(const QByteArray &type, const QByteArray &key); | ||
90 | 93 | | |||
91 | template<typename T> | 94 | template<typename T> | ||
92 | T readEntity(const QByteArray &key) { | 95 | T readEntity(const QByteArray &key) { | ||
93 | return T(readEntity(ApplicationDomain::getTypeName<T>(), key)); | 96 | return T(readEntity(ApplicationDomain::getTypeName<T>(), key)); | ||
94 | } | 97 | } | ||
95 | 98 | | |||
96 | 99 | | |||
97 | void readPrevious(const QByteArray &type, const QByteArray &uid, qint64 revision, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | 100 | void readPrevious(const QByteArray &type, const Sink::Storage::Identifier &id, qint64 revision, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | ||
98 | void readPrevious(const QByteArray &type, const QByteArray &uid, qint64 revision, const std::function<void(const ApplicationDomainType &entity)> callback); | 101 | void readPrevious(const QByteArray &type, const Sink::Storage::Identifier &id, qint64 revision, const std::function<void(const ApplicationDomainType &entity)> callback); | ||
99 | ///Returns a copy | 102 | ///Returns a copy | ||
100 | ApplicationDomainType readPrevious(const QByteArray &type, const QByteArray &uid, qint64 revision); | 103 | ApplicationDomainType readPrevious(const QByteArray &type, const Sink::Storage::Identifier &id, qint64 revision); | ||
101 | 104 | | |||
102 | template<typename T> | 105 | template<typename T> | ||
103 | T readPrevious(const QByteArray &uid, qint64 revision) { | 106 | T readPrevious(const QByteArray &uid, qint64 revision) { | ||
104 | return T(readPrevious(ApplicationDomain::getTypeName<T>(), uid, revision)); | 107 | return T(readPrevious(ApplicationDomain::getTypeName<T>(), uid, revision)); | ||
105 | } | 108 | } | ||
106 | 109 | | |||
107 | void readAllUids(const QByteArray &type, const std::function<void(const QByteArray &uid)> callback); | 110 | void readAllUids(const QByteArray &type, const std::function<void(const QByteArray &uid)> callback); | ||
108 | 111 | | |||
109 | void readAll(const QByteArray &type, const std::function<void(const ApplicationDomainType &entity)> &callback); | 112 | void readAll(const QByteArray &type, const std::function<void(const ApplicationDomainType &entity)> &callback); | ||
110 | 113 | | |||
111 | template<typename T> | 114 | template<typename T> | ||
112 | void readAll(const std::function<void(const T &entity)> &callback) { | 115 | void readAll(const std::function<void(const T &entity)> &callback) { | ||
113 | return readAll(ApplicationDomain::getTypeName<T>(), [&](const ApplicationDomainType &entity) { | 116 | return readAll(ApplicationDomain::getTypeName<T>(), [&](const ApplicationDomainType &entity) { | ||
114 | callback(T(entity)); | 117 | callback(T(entity)); | ||
115 | }); | 118 | }); | ||
116 | } | 119 | } | ||
117 | 120 | | |||
118 | void readRevisions(qint64 baseRevision, const QByteArray &type, const std::function<void(const QByteArray &key)> &callback); | 121 | void readRevisions(qint64 baseRevision, const QByteArray &type, const std::function<void(const Key &key)> &callback); | ||
119 | 122 | | |||
120 | ///Db contains entity (but may already be marked as removed | 123 | ///Db contains entity (but may already be marked as removed | ||
121 | bool contains(const QByteArray &type, const QByteArray &uid); | 124 | bool contains(const QByteArray &type, const QByteArray &uid); | ||
122 | 125 | | |||
123 | ///Db contains entity and entity is not yet removed | 126 | ///Db contains entity and entity is not yet removed | ||
124 | bool exists(const QByteArray &type, const QByteArray &uid); | 127 | bool exists(const QByteArray &type, const QByteArray &uid); | ||
125 | 128 | | |||
126 | void readRevisions(const QByteArray &type, const QByteArray &uid, qint64 baseRevision, const std::function<void(const QByteArray &uid, qint64 revision, const EntityBuffer &entity)> callback); | 129 | void readRevisions(const QByteArray &type, const QByteArray &uid, qint64 baseRevision, const std::function<void(const QByteArray &uid, qint64 revision, const EntityBuffer &entity)> callback); | ||
Show All 17 Lines |