summaryrefslogtreecommitdiffstats
path: root/common/domain
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-21 13:09:46 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-21 13:13:56 +0100
commit7a98c9853726ed09abd35a447f9854c5459a855d (patch)
tree50aa14c43ab616529d35fdf91f6ed8d69887c8ab /common/domain
parenta2a4d09cbd42d3de8380ee0061a80cdc0bfb4e6c (diff)
downloadsink-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')
-rw-r--r--common/domain/addressbook.cpp54
-rw-r--r--common/domain/addressbook.h51
-rw-r--r--common/domain/contact.cpp60
-rw-r--r--common/domain/contact.h58
-rw-r--r--common/domain/domaintypes.h6
-rw-r--r--common/domain/event.cpp57
-rw-r--r--common/domain/event.h57
-rw-r--r--common/domain/folder.cpp60
-rw-r--r--common/domain/folder.h51
-rw-r--r--common/domain/mail.h52
-rw-r--r--common/domain/typeimplementations.cpp (renamed from common/domain/mail.cpp)116
-rw-r--r--common/domain/typeimplementations.h122
12 files changed, 237 insertions, 507 deletions
diff --git a/common/domain/addressbook.cpp b/common/domain/addressbook.cpp
deleted file mode 100644
index d1a3eaf..0000000
--- a/common/domain/addressbook.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2017 Christian Mollekopf <chrigi_1@fastaddressbook.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#include "addressbook.h"
20
21#include <QByteArray>
22#include <QString>
23
24#include "../propertymapper.h"
25#include "../typeindex.h"
26#include "entitybuffer.h"
27#include "entity_generated.h"
28
29#include "addressbook_generated.h"
30
31using namespace Sink::ApplicationDomain;
32
33void TypeImplementation<Addressbook>::configure(TypeIndex &index)
34{
35 index.addProperty<QByteArray>(Addressbook::Parent::name);
36 index.addProperty<QString>(Addressbook::Name::name);
37}
38
39void TypeImplementation<Addressbook>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
40{
41 propertyMapper.addMapping<Addressbook::Parent, Buffer>(&Buffer::parent);
42 propertyMapper.addMapping<Addressbook::Name, Buffer>(&Buffer::name);
43}
44
45void TypeImplementation<Addressbook>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
46{
47 propertyMapper.addMapping<Addressbook::Parent>(&BufferBuilder::add_parent);
48 propertyMapper.addMapping<Addressbook::Name>(&BufferBuilder::add_name);
49}
50
51void TypeImplementation<Addressbook>::configure(IndexPropertyMapper &)
52{
53
54}
diff --git a/common/domain/addressbook.h b/common/domain/addressbook.h
deleted file mode 100644
index 6475073..0000000
--- a/common/domain/addressbook.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * Copyright (C) 2017 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
23template<typename T>
24class ReadPropertyMapper;
25template<typename T>
26class WritePropertyMapper;
27class IndexPropertyMapper;
28
29class TypeIndex;
30
31namespace Sink {
32
33namespace ApplicationDomain {
34 namespace Buffer {
35 struct Addressbook;
36 struct AddressbookBuilder;
37 }
38
39template<>
40class TypeImplementation<Sink::ApplicationDomain::Addressbook> {
41public:
42 typedef Sink::ApplicationDomain::Buffer::Addressbook Buffer;
43 typedef Sink::ApplicationDomain::Buffer::AddressbookBuilder BufferBuilder;
44 static void configure(TypeIndex &);
45 static void configure(ReadPropertyMapper<Buffer> &);
46 static void configure(WritePropertyMapper<BufferBuilder> &);
47 static void configure(IndexPropertyMapper &indexPropertyMapper);
48};
49
50}
51}
diff --git a/common/domain/contact.cpp b/common/domain/contact.cpp
deleted file mode 100644
index 01f9144..0000000
--- a/common/domain/contact.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (C) 2017 Sandro Knauß <knauss@kolabsys.com>
3 * Copyright (C) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20#include "contact.h"
21
22#include <QVector>
23#include <QByteArray>
24#include <QString>
25
26#include "../propertymapper.h"
27#include "../typeindex.h"
28#include "entity_generated.h"
29
30#include "contact_generated.h"
31
32using namespace Sink::ApplicationDomain;
33
34void TypeImplementation<Contact>::configure(TypeIndex &index)
35{
36 index.addProperty<QByteArray>(Contact::Uid::name);
37}
38
39void TypeImplementation<Contact>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
40{
41 propertyMapper.addMapping<Contact::Uid, Buffer>(&Buffer::uid);
42 propertyMapper.addMapping<Contact::Fn, Buffer>(&Buffer::fn);
43 propertyMapper.addMapping<Contact::Emails, Buffer>(&Buffer::emails);
44 propertyMapper.addMapping<Contact::Vcard, Buffer>(&Buffer::vcard);
45 propertyMapper.addMapping<Contact::Addressbook, Buffer>(&Buffer::addressbook);
46}
47
48void TypeImplementation<Contact>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
49{
50 propertyMapper.addMapping<Contact::Uid>(&BufferBuilder::add_uid);
51 propertyMapper.addMapping<Contact::Fn>(&BufferBuilder::add_fn);
52 propertyMapper.addMapping<Contact::Emails>(&BufferBuilder::add_emails);
53 propertyMapper.addMapping<Contact::Vcard>(&BufferBuilder::add_vcard);
54 propertyMapper.addMapping<Contact::Addressbook>(&BufferBuilder::add_addressbook);
55}
56
57void TypeImplementation<Contact>::configure(IndexPropertyMapper &)
58{
59
60}
diff --git a/common/domain/contact.h b/common/domain/contact.h
deleted file mode 100644
index 976f16e..0000000
--- a/common/domain/contact.h
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright (C) 2017 Sandro Knauß <knauss@kolabsys.com>
3 * Copyright (C) 2017 Christian Mollekopf <mollekopf@kolabsys.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20#pragma once
21
22#include "applicationdomaintype.h"
23
24class QByteArray;
25
26template<typename T>
27class ReadPropertyMapper;
28template<typename T>
29class WritePropertyMapper;
30class IndexPropertyMapper;
31
32class TypeIndex;
33
34namespace Sink {
35namespace ApplicationDomain {
36 namespace Buffer {
37 struct Contact;
38 struct ContactBuilder;
39 }
40
41/**
42 * Implements all type-specific code such as updating and querying indexes.
43 *
44 * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation.
45 */
46template<>
47class TypeImplementation<Sink::ApplicationDomain::Contact> {
48public:
49 typedef Sink::ApplicationDomain::Buffer::Contact Buffer;
50 typedef Sink::ApplicationDomain::Buffer::ContactBuilder BufferBuilder;
51 static void configure(TypeIndex &);
52 static void configure(ReadPropertyMapper<Buffer> &);
53 static void configure(WritePropertyMapper<BufferBuilder> &);
54 static void configure(IndexPropertyMapper &indexPropertyMapper);
55};
56
57}
58}
diff --git a/common/domain/domaintypes.h b/common/domain/domaintypes.h
deleted file mode 100644
index 8e31d48..0000000
--- a/common/domain/domaintypes.h
+++ /dev/null
@@ -1,6 +0,0 @@
1
2#include "contact.h"
3#include "addressbook.h"
4#include "mail.h"
5#include "folder.h"
6#include "event.h"
diff --git a/common/domain/event.cpp b/common/domain/event.cpp
deleted file mode 100644
index 10c92bb..0000000
--- a/common/domain/event.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (C) 2014 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#include "event.h"
20
21#include <QVector>
22#include <QByteArray>
23#include <QString>
24
25#include "../propertymapper.h"
26#include "../typeindex.h"
27#include "entity_generated.h"
28
29#include "event_generated.h"
30
31using namespace Sink::ApplicationDomain;
32
33void TypeImplementation<Event>::configure(TypeIndex &index)
34{
35 index.addProperty<QByteArray>(Event::Uid::name);
36}
37
38void TypeImplementation<Event>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
39{
40 propertyMapper.addMapping<Event::Summary, Buffer>(&Buffer::summary);
41 propertyMapper.addMapping<Event::Description, Buffer>(&Buffer::description);
42 propertyMapper.addMapping<Event::Uid, Buffer>(&Buffer::uid);
43 propertyMapper.addMapping<Event::Attachment, Buffer>(&Buffer::attachment);
44}
45
46void TypeImplementation<Event>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
47{
48 propertyMapper.addMapping<Event::Summary>(&BufferBuilder::add_summary);
49 propertyMapper.addMapping<Event::Description>(&BufferBuilder::add_description);
50 propertyMapper.addMapping<Event::Uid>(&BufferBuilder::add_uid);
51 propertyMapper.addMapping<Event::Attachment>(&BufferBuilder::add_attachment);
52}
53
54void TypeImplementation<Event>::configure(IndexPropertyMapper &)
55{
56
57}
diff --git a/common/domain/event.h b/common/domain/event.h
deleted file mode 100644
index b683f5f..0000000
--- a/common/domain/event.h
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (C) 2014 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
23class QByteArray;
24
25template<typename T>
26class ReadPropertyMapper;
27template<typename T>
28class WritePropertyMapper;
29class IndexPropertyMapper;
30
31class TypeIndex;
32
33namespace Sink {
34namespace ApplicationDomain {
35 namespace Buffer {
36 struct Event;
37 struct EventBuilder;
38 }
39
40/**
41 * Implements all type-specific code such as updating and querying indexes.
42 *
43 * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation.
44 */
45template<>
46class TypeImplementation<Sink::ApplicationDomain::Event> {
47public:
48 typedef Sink::ApplicationDomain::Buffer::Event Buffer;
49 typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder;
50 static void configure(TypeIndex &);
51 static void configure(ReadPropertyMapper<Buffer> &);
52 static void configure(WritePropertyMapper<BufferBuilder> &);
53 static void configure(IndexPropertyMapper &indexPropertyMapper);
54};
55
56}
57}
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp
deleted file mode 100644
index 6717661..0000000
--- a/common/domain/folder.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastfolder.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#include "folder.h"
20
21#include <QByteArray>
22#include <QString>
23
24#include "../propertymapper.h"
25#include "../typeindex.h"
26#include "entitybuffer.h"
27#include "entity_generated.h"
28
29#include "folder_generated.h"
30
31using namespace Sink::ApplicationDomain;
32
33void TypeImplementation<Folder>::configure(TypeIndex &index)
34{
35 index.addProperty<QByteArray>(Folder::Parent::name);
36 index.addProperty<QString>(Folder::Name::name);
37}
38
39void TypeImplementation<Folder>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
40{
41 propertyMapper.addMapping<Folder::Parent, Buffer>(&Buffer::parent);
42 propertyMapper.addMapping<Folder::Name, Buffer>(&Buffer::name);
43 propertyMapper.addMapping<Folder::Icon, Buffer>(&Buffer::icon);
44 propertyMapper.addMapping<Folder::SpecialPurpose, Buffer>(&Buffer::specialpurpose);
45 propertyMapper.addMapping<Folder::Enabled, Buffer>(&Buffer::enabled);
46}
47
48void TypeImplementation<Folder>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
49{
50 propertyMapper.addMapping<Folder::Parent>(&BufferBuilder::add_parent);
51 propertyMapper.addMapping<Folder::Name>(&BufferBuilder::add_name);
52 propertyMapper.addMapping<Folder::Icon>(&BufferBuilder::add_icon);
53 propertyMapper.addMapping<Folder::SpecialPurpose>(&BufferBuilder::add_specialpurpose);
54 propertyMapper.addMapping<Folder::Enabled>(&BufferBuilder::add_enabled);
55}
56
57void TypeImplementation<Folder>::configure(IndexPropertyMapper &)
58{
59
60}
diff --git a/common/domain/folder.h b/common/domain/folder.h
deleted file mode 100644
index f232ab5..0000000
--- a/common/domain/folder.h
+++ /dev/null
@@ -1,51 +0,0 @@
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
23template<typename T>
24class ReadPropertyMapper;
25template<typename T>
26class WritePropertyMapper;
27class IndexPropertyMapper;
28
29class TypeIndex;
30
31namespace Sink {
32
33namespace ApplicationDomain {
34 namespace Buffer {
35 struct Folder;
36 struct FolderBuilder;
37 }
38
39template<>
40class TypeImplementation<Sink::ApplicationDomain::Folder> {
41public:
42 typedef Sink::ApplicationDomain::Buffer::Folder Buffer;
43 typedef Sink::ApplicationDomain::Buffer::FolderBuilder BufferBuilder;
44 static void configure(TypeIndex &);
45 static void configure(ReadPropertyMapper<Buffer> &);
46 static void configure(WritePropertyMapper<BufferBuilder> &);
47 static void configure(IndexPropertyMapper &indexPropertyMapper);
48};
49
50}
51}
diff --git a/common/domain/mail.h b/common/domain/mail.h
deleted file mode 100644
index e052448..0000000
--- a/common/domain/mail.h
+++ /dev/null
@@ -1,52 +0,0 @@
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
23class QByteArray;
24
25template<typename T>
26class ReadPropertyMapper;
27template<typename T>
28class WritePropertyMapper;
29class IndexPropertyMapper;
30
31class TypeIndex;
32
33namespace Sink {
34namespace ApplicationDomain {
35 namespace Buffer {
36 struct Mail;
37 struct MailBuilder;
38 }
39
40template<>
41class TypeImplementation<Sink::ApplicationDomain::Mail> {
42public:
43 typedef Sink::ApplicationDomain::Buffer::Mail Buffer;
44 typedef Sink::ApplicationDomain::Buffer::MailBuilder BufferBuilder;
45 static void configure(TypeIndex &index);
46 static void configure(ReadPropertyMapper<Buffer> &propertyMapper);
47 static void configure(WritePropertyMapper<BufferBuilder> &propertyMapper);
48 static void configure(IndexPropertyMapper &indexPropertyMapper);
49};
50
51}
52}
diff --git a/common/domain/mail.cpp b/common/domain/typeimplementations.cpp
index 8cbe61b..38422f4 100644
--- a/common/domain/mail.cpp
+++ b/common/domain/typeimplementations.cpp
@@ -16,7 +16,7 @@
16 * Free Software Foundation, Inc., 16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */ 18 */
19#include "mail.h" 19#include "typeimplementations.h"
20 20
21#include <QVector> 21#include <QVector>
22#include <QByteArray> 22#include <QByteArray>
@@ -30,6 +30,10 @@
30#include "domainadaptor.h" 30#include "domainadaptor.h"
31 31
32#include "mail_generated.h" 32#include "mail_generated.h"
33#include "folder_generated.h"
34#include "event_generated.h"
35#include "contact_generated.h"
36#include "addressbook_generated.h"
33 37
34using namespace Sink; 38using namespace Sink;
35using namespace Sink::ApplicationDomain; 39using namespace Sink::ApplicationDomain;
@@ -102,3 +106,113 @@ void TypeImplementation<Mail>::configure(WritePropertyMapper<BufferBuilder> &pro
102 propertyMapper.addMapping<Mail::MessageId>(&BufferBuilder::add_messageId); 106 propertyMapper.addMapping<Mail::MessageId>(&BufferBuilder::add_messageId);
103 propertyMapper.addMapping<Mail::ParentMessageId>(&BufferBuilder::add_parentMessageId); 107 propertyMapper.addMapping<Mail::ParentMessageId>(&BufferBuilder::add_parentMessageId);
104} 108}
109
110
111void TypeImplementation<Folder>::configure(TypeIndex &index)
112{
113 index.addProperty<QByteArray>(Folder::Parent::name);
114 index.addProperty<QString>(Folder::Name::name);
115}
116
117void TypeImplementation<Folder>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
118{
119 propertyMapper.addMapping<Folder::Parent, Buffer>(&Buffer::parent);
120 propertyMapper.addMapping<Folder::Name, Buffer>(&Buffer::name);
121 propertyMapper.addMapping<Folder::Icon, Buffer>(&Buffer::icon);
122 propertyMapper.addMapping<Folder::SpecialPurpose, Buffer>(&Buffer::specialpurpose);
123 propertyMapper.addMapping<Folder::Enabled, Buffer>(&Buffer::enabled);
124}
125
126void TypeImplementation<Folder>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
127{
128 propertyMapper.addMapping<Folder::Parent>(&BufferBuilder::add_parent);
129 propertyMapper.addMapping<Folder::Name>(&BufferBuilder::add_name);
130 propertyMapper.addMapping<Folder::Icon>(&BufferBuilder::add_icon);
131 propertyMapper.addMapping<Folder::SpecialPurpose>(&BufferBuilder::add_specialpurpose);
132 propertyMapper.addMapping<Folder::Enabled>(&BufferBuilder::add_enabled);
133}
134
135void TypeImplementation<Folder>::configure(IndexPropertyMapper &)
136{
137
138}
139
140
141void TypeImplementation<Contact>::configure(TypeIndex &index)
142{
143 index.addProperty<QByteArray>(Contact::Uid::name);
144}
145
146void TypeImplementation<Contact>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
147{
148 propertyMapper.addMapping<Contact::Uid, Buffer>(&Buffer::uid);
149 propertyMapper.addMapping<Contact::Fn, Buffer>(&Buffer::fn);
150 propertyMapper.addMapping<Contact::Emails, Buffer>(&Buffer::emails);
151 propertyMapper.addMapping<Contact::Vcard, Buffer>(&Buffer::vcard);
152 propertyMapper.addMapping<Contact::Addressbook, Buffer>(&Buffer::addressbook);
153}
154
155void TypeImplementation<Contact>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
156{
157 propertyMapper.addMapping<Contact::Uid>(&BufferBuilder::add_uid);
158 propertyMapper.addMapping<Contact::Fn>(&BufferBuilder::add_fn);
159 propertyMapper.addMapping<Contact::Emails>(&BufferBuilder::add_emails);
160 propertyMapper.addMapping<Contact::Vcard>(&BufferBuilder::add_vcard);
161 propertyMapper.addMapping<Contact::Addressbook>(&BufferBuilder::add_addressbook);
162}
163
164void TypeImplementation<Contact>::configure(IndexPropertyMapper &)
165{
166
167}
168
169
170void TypeImplementation<Addressbook>::configure(TypeIndex &index)
171{
172 index.addProperty<QByteArray>(Addressbook::Parent::name);
173 index.addProperty<QString>(Addressbook::Name::name);
174}
175
176void TypeImplementation<Addressbook>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
177{
178 propertyMapper.addMapping<Addressbook::Parent, Buffer>(&Buffer::parent);
179 propertyMapper.addMapping<Addressbook::Name, Buffer>(&Buffer::name);
180}
181
182void TypeImplementation<Addressbook>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
183{
184 propertyMapper.addMapping<Addressbook::Parent>(&BufferBuilder::add_parent);
185 propertyMapper.addMapping<Addressbook::Name>(&BufferBuilder::add_name);
186}
187
188void TypeImplementation<Addressbook>::configure(IndexPropertyMapper &)
189{
190
191}
192
193
194void TypeImplementation<Event>::configure(TypeIndex &index)
195{
196 index.addProperty<QByteArray>(Event::Uid::name);
197}
198
199void TypeImplementation<Event>::configure(ReadPropertyMapper<Buffer> &propertyMapper)
200{
201 propertyMapper.addMapping<Event::Summary, Buffer>(&Buffer::summary);
202 propertyMapper.addMapping<Event::Description, Buffer>(&Buffer::description);
203 propertyMapper.addMapping<Event::Uid, Buffer>(&Buffer::uid);
204 propertyMapper.addMapping<Event::Attachment, Buffer>(&Buffer::attachment);
205}
206
207void TypeImplementation<Event>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper)
208{
209 propertyMapper.addMapping<Event::Summary>(&BufferBuilder::add_summary);
210 propertyMapper.addMapping<Event::Description>(&BufferBuilder::add_description);
211 propertyMapper.addMapping<Event::Uid>(&BufferBuilder::add_uid);
212 propertyMapper.addMapping<Event::Attachment>(&BufferBuilder::add_attachment);
213}
214
215void TypeImplementation<Event>::configure(IndexPropertyMapper &)
216{
217
218}
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
23class QByteArray;
24
25template<typename T>
26class ReadPropertyMapper;
27template<typename T>
28class WritePropertyMapper;
29class IndexPropertyMapper;
30
31class 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 */
38namespace Sink {
39namespace ApplicationDomain {
40
41namespace Buffer {
42 struct Mail;
43 struct MailBuilder;
44}
45
46template<>
47class TypeImplementation<Sink::ApplicationDomain::Mail> {
48public:
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
57namespace Buffer {
58 struct Folder;
59 struct FolderBuilder;
60}
61
62template<>
63class TypeImplementation<Sink::ApplicationDomain::Folder> {
64public:
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
73namespace Buffer {
74 struct Contact;
75 struct ContactBuilder;
76}
77
78template<>
79class TypeImplementation<Sink::ApplicationDomain::Contact> {
80public:
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
89namespace Buffer {
90 struct Addressbook;
91 struct AddressbookBuilder;
92}
93
94template<>
95class TypeImplementation<Sink::ApplicationDomain::Addressbook> {
96public:
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
105namespace Buffer {
106 struct Event;
107 struct EventBuilder;
108}
109
110template<>
111class TypeImplementation<Sink::ApplicationDomain::Event> {
112public:
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}