diff options
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r-- | common/storage/entitystore.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index f6b8f43..b6251b6 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "index.h" | 27 | #include "index.h" |
28 | #include "bufferutils.h" | 28 | #include "bufferutils.h" |
29 | #include "entity_generated.h" | 29 | #include "entity_generated.h" |
30 | #include "applicationdomaintype_p.h" | ||
30 | 31 | ||
31 | #include "mail.h" | 32 | #include "mail.h" |
32 | #include "folder.h" | 33 | #include "folder.h" |
@@ -57,20 +58,12 @@ public: | |||
57 | return transaction; | 58 | return transaction; |
58 | } | 59 | } |
59 | 60 | ||
60 | template<typename ...Args> | 61 | template <class T> |
61 | void configure(const QByteArray &type, Args && ... args) | 62 | struct ConfigureHelper { |
62 | { | 63 | void operator()(TypeIndex &arg) const { |
63 | if (type == ApplicationDomain::getTypeName<ApplicationDomain::Folder>()) { | 64 | ApplicationDomain::TypeImplementation<T>::configure(arg); |
64 | ApplicationDomain::TypeImplementation<ApplicationDomain::Folder>::configure(std::forward<Args...>(args...)); | ||
65 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Mail>()) { | ||
66 | ApplicationDomain::TypeImplementation<ApplicationDomain::Mail>::configure(std::forward<Args...>(args...)); | ||
67 | } else if (type == ApplicationDomain::getTypeName<ApplicationDomain::Event>()) { | ||
68 | ApplicationDomain::TypeImplementation<ApplicationDomain::Event>::configure(std::forward<Args...>(args...)); | ||
69 | } else { | ||
70 | Q_ASSERT(false); | ||
71 | SinkError() << "Unkonwn type " << type; | ||
72 | } | 65 | } |
73 | } | 66 | }; |
74 | 67 | ||
75 | TypeIndex &cachedIndex(const QByteArray &type) | 68 | TypeIndex &cachedIndex(const QByteArray &type) |
76 | { | 69 | { |
@@ -78,7 +71,7 @@ public: | |||
78 | return *indexByType.value(type); | 71 | return *indexByType.value(type); |
79 | } | 72 | } |
80 | auto index = QSharedPointer<TypeIndex>::create(type); | 73 | auto index = QSharedPointer<TypeIndex>::create(type); |
81 | configure(type, *index); | 74 | TypeHelper<ConfigureHelper>{type}.template operator()<void>(*index); |
82 | indexByType.insert(type, index); | 75 | indexByType.insert(type, index); |
83 | return *index; | 76 | return *index; |
84 | 77 | ||