summaryrefslogtreecommitdiffstats
path: root/common/query.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-08 13:18:19 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-08 13:18:19 +0100
commitae4b64b198a143240aa5dd1e202e5016abfdae71 (patch)
tree5d9d58a512ebc60c44637d11c9424f67a02887e8 /common/query.h
parentf425c2070131161dc11bcf70e35f8d1848cadb65 (diff)
downloadsink-ae4b64b198a143240aa5dd1e202e5016abfdae71.tar.gz
sink-ae4b64b198a143240aa5dd1e202e5016abfdae71.zip
Wrap references in a Reerence type.
This allows us to make sure that references are not taken out of context (the resource). Because we need to use the type-specific accessors more we also ran into a problem that we cannot "downcast" a reference with the change recording still working, for that we have the cast<T>() operator now.
Diffstat (limited to 'common/query.h')
-rw-r--r--common/query.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/query.h b/common/query.h
index b69639b..c265f92 100644
--- a/common/query.h
+++ b/common/query.h
@@ -325,16 +325,17 @@ public:
325 } 325 }
326 326
327 template <typename T> 327 template <typename T>
328 Query &filter(const QVariant &value) 328 Query &filter(const typename T::Type &value)
329 { 329 {
330 filter(T::name, value); 330 filter(T::name, QVariant::fromValue(value));
331 return *this; 331 return *this;
332 } 332 }
333 333
334 template <typename T> 334 template <typename T>
335 Query &containsFilter(const QVariant &value) 335 Query &containsFilter(const QByteArray &value)
336 { 336 {
337 QueryBase::filter(T::name, QueryBase::Comparator(value, QueryBase::Comparator::Contains)); 337 static_assert(std::is_same<typename T::Type, QByteArrayList>::value, "The contains filter is only implemented for QByteArray in QByteArrayList");
338 QueryBase::filter(T::name, QueryBase::Comparator(QVariant::fromValue(value), QueryBase::Comparator::Contains));
338 return *this; 339 return *this;
339 } 340 }
340 341
@@ -366,7 +367,7 @@ public:
366 template <typename T> 367 template <typename T>
367 Query &filter(const ApplicationDomain::Entity &value) 368 Query &filter(const ApplicationDomain::Entity &value)
368 { 369 {
369 filter(T::name, QVariant::fromValue(value.identifier())); 370 filter(T::name, QVariant::fromValue(ApplicationDomain::Reference{value.identifier()}));
370 return *this; 371 return *this;
371 } 372 }
372 373