diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-15 17:54:58 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-16 10:39:59 +0100 |
commit | 0ecabf708cd56e0312392cca6d85aa8c3f2e7ccc (patch) | |
tree | 178a689a3be37e513ac9f7d1a2117b802f8ec17c /sinksh | |
parent | f7a42de9bfd6e34f1dc46da433d3f45976b1cd0e (diff) | |
download | sink-0ecabf708cd56e0312392cca6d85aa8c3f2e7ccc.tar.gz sink-0ecabf708cd56e0312392cca6d85aa8c3f2e7ccc.zip |
Use SINK_REGISTER_TYPES to avoid repeating the types
Diffstat (limited to 'sinksh')
-rw-r--r-- | sinksh/sinksh_utils.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/sinksh/sinksh_utils.cpp b/sinksh/sinksh_utils.cpp index 9a0d1d8..3bbffef 100644 --- a/sinksh/sinksh_utils.cpp +++ b/sinksh/sinksh_utils.cpp | |||
@@ -36,31 +36,15 @@ StoreBase &getStore(const QString &type) | |||
36 | { | 36 | { |
37 | using namespace Sink::ApplicationDomain; | 37 | using namespace Sink::ApplicationDomain; |
38 | 38 | ||
39 | if (type == getTypeName<Folder>()) { | 39 | #define REGISTER_TYPE(TYPE) \ |
40 | static Store<Folder> store; | 40 | if (type == getTypeName<TYPE>()) { static Store<TYPE> store; return store; } else |
41 | return store; | 41 | SINK_REGISTER_TYPES() |
42 | } else if (type == getTypeName<Mail>()) { | 42 | #undef REGISTER_TYPE |
43 | static Store<Mail> store; | 43 | { |
44 | return store; | 44 | SinkWarning_("", "") << "Trying to get a store that doesn't exist: " << type; |
45 | } else if (type == getTypeName<Event>()) { | 45 | Q_ASSERT(false); |
46 | static Store<Event> store; | 46 | } |
47 | return store; | ||
48 | } else if (type == getTypeName<SinkResource>()) { | ||
49 | static Store<SinkResource> store; | ||
50 | return store; | ||
51 | } else if (type == getTypeName<SinkAccount>()) { | ||
52 | static Store<SinkAccount> store; | ||
53 | return store; | ||
54 | } else if (type == getTypeName<Identity>()) { | ||
55 | static Store<Identity> store; | ||
56 | return store; | ||
57 | } else if (type == getTypeName<Contact>()) { | ||
58 | static Store<Contact> store; | ||
59 | return store; | ||
60 | } | ||
61 | 47 | ||
62 | SinkWarning_("", "") << "Trying to get a store that doesn't exist: " << type; | ||
63 | Q_ASSERT(false); | ||
64 | static DummyStore store; | 48 | static DummyStore store; |
65 | return store; | 49 | return store; |
66 | } | 50 | } |