summaryrefslogtreecommitdiffstats
path: root/common/resultset.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-15 09:35:43 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-15 09:35:43 +0100
commitfb0df0d8008ef05cfa94936e19c22dec0faaa8e4 (patch)
tree0918986d77c4951f394e12d3e114c126eec18094 /common/resultset.h
parente5dd64ba354aef193c5516d9a58e1d724220c55b (diff)
downloadsink-fb0df0d8008ef05cfa94936e19c22dec0faaa8e4.tar.gz
sink-fb0df0d8008ef05cfa94936e19c22dec0faaa8e4.zip
Prepared querying of batches and added a switch to enable/disable
sorting
Diffstat (limited to 'common/resultset.h')
-rw-r--r--common/resultset.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/common/resultset.h b/common/resultset.h
index 2ca8800..8a0720d 100644
--- a/common/resultset.h
+++ b/common/resultset.h
@@ -32,6 +32,7 @@ class ResultSet {
32 public: 32 public:
33 typedef std::function<bool(std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)>)> ValueGenerator; 33 typedef std::function<bool(std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)>)> ValueGenerator;
34 typedef std::function<QByteArray()> IdGenerator; 34 typedef std::function<QByteArray()> IdGenerator;
35 typedef std::function<void()> SkipValue;
35 36
36 ResultSet() 37 ResultSet()
37 : mIt(nullptr) 38 : mIt(nullptr)
@@ -39,23 +40,30 @@ class ResultSet {
39 40
40 } 41 }
41 42
42 ResultSet(const ValueGenerator &generator) 43 ResultSet(const ValueGenerator &generator, const SkipValue &skip)
43 : mIt(nullptr), 44 : mIt(nullptr),
44 mValueGenerator(generator) 45 mValueGenerator(generator),
46 mSkip(skip)
45 { 47 {
46 48
47 } 49 }
48 50
49 ResultSet(const IdGenerator &generator) 51 ResultSet(const IdGenerator &generator)
50 : mIt(nullptr), 52 : mIt(nullptr),
51 mGenerator(generator) 53 mGenerator(generator),
54 mSkip([this]() {
55 mGenerator();
56 })
52 { 57 {
53 58
54 } 59 }
55 60
56 ResultSet(const QVector<QByteArray> &resultSet) 61 ResultSet(const QVector<QByteArray> &resultSet)
57 : mResultSet(resultSet), 62 : mResultSet(resultSet),
58 mIt(nullptr) 63 mIt(nullptr),
64 mSkip([this]() {
65 mGenerator();
66 })
59 { 67 {
60 68
61 } 69 }
@@ -99,6 +107,14 @@ class ResultSet {
99 return false; 107 return false;
100 } 108 }
101 109
110 void skip(int number)
111 {
112 Q_ASSERT(mSkip);
113 for (int i = 0; i < number; i++) {
114 mSkip();
115 }
116 }
117
102 QByteArray id() 118 QByteArray id()
103 { 119 {
104 if (mIt) { 120 if (mIt) {
@@ -119,5 +135,6 @@ class ResultSet {
119 QByteArray mCurrentValue; 135 QByteArray mCurrentValue;
120 IdGenerator mGenerator; 136 IdGenerator mGenerator;
121 ValueGenerator mValueGenerator; 137 ValueGenerator mValueGenerator;
138 SkipValue mSkip;
122}; 139};
123 140