diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-21 13:09:46 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-21 13:13:56 +0100 |
commit | 7a98c9853726ed09abd35a447f9854c5459a855d (patch) | |
tree | 50aa14c43ab616529d35fdf91f6ed8d69887c8ab /common/domain/typeimplementations.h | |
parent | a2a4d09cbd42d3de8380ee0061a80cdc0bfb4e6c (diff) | |
download | sink-7a98c9853726ed09abd35a447f9854c5459a855d.tar.gz sink-7a98c9853726ed09abd35a447f9854c5459a855d.zip |
Move type implementations in one place
Having them separated is rather pointless (since we need one for every
type, and all types are the interface of sink, as one), and caused quite
a bit of friction when adding new types. This will also make it easier
to change things for all types.
Diffstat (limited to 'common/domain/typeimplementations.h')
-rw-r--r-- | common/domain/typeimplementations.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/common/domain/typeimplementations.h b/common/domain/typeimplementations.h new file mode 100644 index 0000000..cb63949 --- /dev/null +++ b/common/domain/typeimplementations.h | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | class QByteArray; | ||
24 | |||
25 | template<typename T> | ||
26 | class ReadPropertyMapper; | ||
27 | template<typename T> | ||
28 | class WritePropertyMapper; | ||
29 | class IndexPropertyMapper; | ||
30 | |||
31 | class TypeIndex; | ||
32 | |||
33 | /** | ||
34 | * Implements all type-specific code such as updating and querying indexes. | ||
35 | * | ||
36 | * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation. | ||
37 | */ | ||
38 | namespace Sink { | ||
39 | namespace ApplicationDomain { | ||
40 | |||
41 | namespace Buffer { | ||
42 | struct Mail; | ||
43 | struct MailBuilder; | ||
44 | } | ||
45 | |||
46 | template<> | ||
47 | class TypeImplementation<Sink::ApplicationDomain::Mail> { | ||
48 | public: | ||
49 | typedef Sink::ApplicationDomain::Buffer::Mail Buffer; | ||
50 | typedef Sink::ApplicationDomain::Buffer::MailBuilder BufferBuilder; | ||
51 | static void configure(TypeIndex &index); | ||
52 | static void configure(ReadPropertyMapper<Buffer> &propertyMapper); | ||
53 | static void configure(WritePropertyMapper<BufferBuilder> &propertyMapper); | ||
54 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
55 | }; | ||
56 | |||
57 | namespace Buffer { | ||
58 | struct Folder; | ||
59 | struct FolderBuilder; | ||
60 | } | ||
61 | |||
62 | template<> | ||
63 | class TypeImplementation<Sink::ApplicationDomain::Folder> { | ||
64 | public: | ||
65 | typedef Sink::ApplicationDomain::Buffer::Folder Buffer; | ||
66 | typedef Sink::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; | ||
67 | static void configure(TypeIndex &); | ||
68 | static void configure(ReadPropertyMapper<Buffer> &); | ||
69 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
70 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
71 | }; | ||
72 | |||
73 | namespace Buffer { | ||
74 | struct Contact; | ||
75 | struct ContactBuilder; | ||
76 | } | ||
77 | |||
78 | template<> | ||
79 | class TypeImplementation<Sink::ApplicationDomain::Contact> { | ||
80 | public: | ||
81 | typedef Sink::ApplicationDomain::Buffer::Contact Buffer; | ||
82 | typedef Sink::ApplicationDomain::Buffer::ContactBuilder BufferBuilder; | ||
83 | static void configure(TypeIndex &); | ||
84 | static void configure(ReadPropertyMapper<Buffer> &); | ||
85 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
86 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
87 | }; | ||
88 | |||
89 | namespace Buffer { | ||
90 | struct Addressbook; | ||
91 | struct AddressbookBuilder; | ||
92 | } | ||
93 | |||
94 | template<> | ||
95 | class TypeImplementation<Sink::ApplicationDomain::Addressbook> { | ||
96 | public: | ||
97 | typedef Sink::ApplicationDomain::Buffer::Addressbook Buffer; | ||
98 | typedef Sink::ApplicationDomain::Buffer::AddressbookBuilder BufferBuilder; | ||
99 | static void configure(TypeIndex &); | ||
100 | static void configure(ReadPropertyMapper<Buffer> &); | ||
101 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
102 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
103 | }; | ||
104 | |||
105 | namespace Buffer { | ||
106 | struct Event; | ||
107 | struct EventBuilder; | ||
108 | } | ||
109 | |||
110 | template<> | ||
111 | class TypeImplementation<Sink::ApplicationDomain::Event> { | ||
112 | public: | ||
113 | typedef Sink::ApplicationDomain::Buffer::Event Buffer; | ||
114 | typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder; | ||
115 | static void configure(TypeIndex &); | ||
116 | static void configure(ReadPropertyMapper<Buffer> &); | ||
117 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
118 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
119 | }; | ||
120 | |||
121 | } | ||
122 | } | ||