diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-10-09 18:51:04 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-10-10 10:40:01 +0200 |
commit | 6f1d3437b3bdd3ccde1243ceddf19f0c0fb5afda (patch) | |
tree | 0c90df67eac827d5166158c1f7055d00cf39425d /common/resultprovider.h | |
parent | 4f1ec5deaf3205e4d71dcb0ff35a29cfbb2c8ec1 (diff) | |
download | sink-6f1d3437b3bdd3ccde1243ceddf19f0c0fb5afda.tar.gz sink-6f1d3437b3bdd3ccde1243ceddf19f0c0fb5afda.zip |
Modification and removal in results
Now we just need to ensure that equality is tested using the
ApplicationDomainType::identifier
Diffstat (limited to 'common/resultprovider.h')
-rw-r--r-- | common/resultprovider.h | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/common/resultprovider.h b/common/resultprovider.h index 841fd01..bc03152 100644 --- a/common/resultprovider.h +++ b/common/resultprovider.h | |||
@@ -81,6 +81,28 @@ public: | |||
81 | }); | 81 | }); |
82 | } | 82 | } |
83 | 83 | ||
84 | void modify(const T &value) | ||
85 | { | ||
86 | //Because I don't know how to use bind | ||
87 | auto weakEmitter = mResultEmitter; | ||
88 | callInMainThreadOnEmitter([weakEmitter, value](){ | ||
89 | if (auto strongRef = weakEmitter.toStrongRef()) { | ||
90 | strongRef->modifyHandler(value); | ||
91 | } | ||
92 | }); | ||
93 | } | ||
94 | |||
95 | void remove(const T &value) | ||
96 | { | ||
97 | //Because I don't know how to use bind | ||
98 | auto weakEmitter = mResultEmitter; | ||
99 | callInMainThreadOnEmitter([weakEmitter, value](){ | ||
100 | if (auto strongRef = weakEmitter.toStrongRef()) { | ||
101 | strongRef->removeHandler(value); | ||
102 | } | ||
103 | }); | ||
104 | } | ||
105 | |||
84 | void initialResultSetComplete() | 106 | void initialResultSetComplete() |
85 | { | 107 | { |
86 | callInMainThreadOnEmitter(&ResultEmitter<T>::initialResultSetComplete); | 108 | callInMainThreadOnEmitter(&ResultEmitter<T>::initialResultSetComplete); |
@@ -176,15 +198,27 @@ public: | |||
176 | { | 198 | { |
177 | addHandler = handler; | 199 | addHandler = handler; |
178 | } | 200 | } |
179 | // void onRemoved(const std::function<void(const T&)> &handler); | 201 | |
202 | void onModified(const std::function<void(const DomainType&)> &handler) | ||
203 | { | ||
204 | modifyHandler = handler; | ||
205 | } | ||
206 | |||
207 | void onRemoved(const std::function<void(const DomainType&)> &handler) | ||
208 | { | ||
209 | removeHandler = handler; | ||
210 | } | ||
211 | |||
180 | void onInitialResultSetComplete(const std::function<void(void)> &handler) | 212 | void onInitialResultSetComplete(const std::function<void(void)> &handler) |
181 | { | 213 | { |
182 | initialResultSetCompleteHandler = handler; | 214 | initialResultSetCompleteHandler = handler; |
183 | } | 215 | } |
216 | |||
184 | void onComplete(const std::function<void(void)> &handler) | 217 | void onComplete(const std::function<void(void)> &handler) |
185 | { | 218 | { |
186 | completeHandler = handler; | 219 | completeHandler = handler; |
187 | } | 220 | } |
221 | |||
188 | void onClear(const std::function<void(void)> &handler) | 222 | void onClear(const std::function<void(void)> &handler) |
189 | { | 223 | { |
190 | clearHandler = handler; | 224 | clearHandler = handler; |
@@ -195,6 +229,16 @@ public: | |||
195 | addHandler(value); | 229 | addHandler(value); |
196 | } | 230 | } |
197 | 231 | ||
232 | void modify(const DomainType &value) | ||
233 | { | ||
234 | modifyHandler(value); | ||
235 | } | ||
236 | |||
237 | void remove(const DomainType &value) | ||
238 | { | ||
239 | removeHandler(value); | ||
240 | } | ||
241 | |||
198 | void initialResultSetComplete() | 242 | void initialResultSetComplete() |
199 | { | 243 | { |
200 | initialResultSetCompleteHandler(); | 244 | initialResultSetCompleteHandler(); |
@@ -214,7 +258,8 @@ private: | |||
214 | friend class ResultProvider<DomainType>; | 258 | friend class ResultProvider<DomainType>; |
215 | 259 | ||
216 | std::function<void(const DomainType&)> addHandler; | 260 | std::function<void(const DomainType&)> addHandler; |
217 | // std::function<void(const T&)> removeHandler; | 261 | std::function<void(const DomainType&)> modifyHandler; |
262 | std::function<void(const DomainType&)> removeHandler; | ||
218 | std::function<void(void)> initialResultSetCompleteHandler; | 263 | std::function<void(void)> initialResultSetCompleteHandler; |
219 | std::function<void(void)> completeHandler; | 264 | std::function<void(void)> completeHandler; |
220 | std::function<void(void)> clearHandler; | 265 | std::function<void(void)> clearHandler; |