summaryrefslogtreecommitdiffstats
path: root/common/domain
diff options
context:
space:
mode:
Diffstat (limited to 'common/domain')
-rw-r--r--common/domain/typeimplementations.cpp3
-rw-r--r--common/domain/typeimplementations_p.h20
2 files changed, 22 insertions, 1 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp
index a8f4baf..2b2d2ac 100644
--- a/common/domain/typeimplementations.cpp
+++ b/common/domain/typeimplementations.cpp
@@ -65,7 +65,8 @@ typedef IndexConfig<Addressbook,
65 65
66typedef IndexConfig<Event, 66typedef IndexConfig<Event,
67 ValueIndex<Event::Uid>, 67 ValueIndex<Event::Uid>,
68 SortedIndex<Event::StartTime> 68 SortedIndex<Event::StartTime>,
69 SampledPeriodIndex<Event::StartTime, Event::EndTime>
69 > EventIndexConfig; 70 > EventIndexConfig;
70 71
71typedef IndexConfig<Todo, 72typedef IndexConfig<Todo,
diff --git a/common/domain/typeimplementations_p.h b/common/domain/typeimplementations_p.h
index fc08048..51af113 100644
--- a/common/domain/typeimplementations_p.h
+++ b/common/domain/typeimplementations_p.h
@@ -126,6 +126,26 @@ public:
126 } 126 }
127}; 127};
128 128
129template <typename RangeBeginProperty, typename RangeEndProperty>
130class SampledPeriodIndex
131{
132 static_assert(std::is_same<typename RangeBeginProperty::Type, QDateTime>::value &&
133 std::is_same<typename RangeEndProperty::Type, QDateTime>::value,
134 "Date range index is not supported for types other than 'QDateTime's");
135
136public:
137 static void configure(TypeIndex &index)
138 {
139 index.addSampledPeriodIndex<RangeBeginProperty, RangeEndProperty>();
140 }
141
142 template <typename EntityType>
143 static QMap<QByteArray, int> databases()
144 {
145 return {{QByteArray{EntityType::name} +".index." + RangeBeginProperty::name + ".range." + RangeEndProperty::name, 1}};
146 }
147};
148
129template <typename EntityType, typename ... Indexes> 149template <typename EntityType, typename ... Indexes>
130class IndexConfig 150class IndexConfig
131{ 151{