digiKam
coredbbackend_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-06-07
7  * Description : Core database abstract backend.
8  *
9  * Copyright (C) 2007-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_CORE_DB_BACKEND_PRIVATE_H
26 #define DIGIKAM_CORE_DB_BACKEND_PRIVATE_H
27 
28 // Local includes
29 
30 #include "dbenginebackend_p.h"
31 #include "coredbwatch.h"
32 
33 namespace Digikam
34 {
35 
36 class CoreDbWatch;
37 
38 class Q_DECL_HIDDEN CoreDbBackendPrivate : public BdEngineBackendPrivate
39 {
40 public:
41 
42  explicit CoreDbBackendPrivate(CoreDbBackend* const backend)
43  : BdEngineBackendPrivate (backend),
44  watch (nullptr),
45  imageChangesetContainer (this),
46  imageTagChangesetContainer (this),
47  collectionImageChangesetContainer (this),
48  albumChangesetContainer (this),
49  tagChangesetContainer (this),
50  albumRootChangesetContainer (this),
51  searchChangesetContainer (this)
52  {
53  }
54 
55 public:
56 
58 
59 public:
60 
61  void sendToWatch(const ImageChangeset& changeset)
62  {
63  watch->sendImageChange(changeset);
64  }
65 
66  void sendToWatch(const ImageTagChangeset& changeset)
67  {
68  watch->sendImageTagChange(changeset);
69  }
70 
71  void sendToWatch(const CollectionImageChangeset& changeset)
72  {
73  watch->sendCollectionImageChange(changeset);
74  }
75 
76  void sendToWatch(const AlbumChangeset& changeset)
77  {
78  watch->sendAlbumChange(changeset);
79  }
80 
81  void sendToWatch(const TagChangeset& changeset)
82  {
83  watch->sendTagChange(changeset);
84  }
85 
86  void sendToWatch(const AlbumRootChangeset& changeset)
87  {
88  watch->sendAlbumRootChange(changeset);
89  }
90 
91  void sendToWatch(const SearchChangeset& changeset)
92  {
93  watch->sendSearchChange(changeset);
94  }
95 
96  template <class T>
97  class Q_DECL_HIDDEN ChangesetContainer
98  {
99  public:
100 
102  : d(dd)
103  {
104  }
105 
106  void recordChangeset(const T& changeset)
107  {
108  if (d->isInTransaction)
109  {
110  changesets << changeset;
111  }
112  else
113  {
114  d->sendToWatch(changeset);
115  }
116  }
117 
118  void sendOut()
119  {
120  foreach (const T& changeset, changesets)
121  {
122  d->sendToWatch(changeset);
123  }
124 
125  changesets.clear();
126  }
127 
128  public:
129 
132  };
133 
134 public:
135 
143 
144 public:
145 
146  void transactionFinished() override
147  {
149 
150  imageChangesetContainer.sendOut();
151  imageTagChangesetContainer.sendOut();
152  collectionImageChangesetContainer.sendOut();
153  albumChangesetContainer.sendOut();
154  tagChangesetContainer.sendOut();
155  albumRootChangesetContainer.sendOut();
156  searchChangesetContainer.sendOut();
157  }
158 };
159 
160 } // namespace Digikam
161 
162 #endif // DIGIKAM_CORE_DB_BACKEND_PRIVATE_H
Definition: coredbchangesets.h:262
Definition: coredbchangesets.h:337
Definition: dbenginebackend_p.h:67
virtual void transactionFinished()
Definition: dbenginebackend.cpp:381
Definition: coredbchangesets.h:152
void recordChangeset(const T &changeset)
Definition: coredbbackend_p.h:106
CoreDbBackendPrivate *const d
Definition: coredbbackend_p.h:131
QList< T > changesets
Definition: coredbbackend_p.h:130
ChangesetContainer(CoreDbBackendPrivate *const dd)
Definition: coredbbackend_p.h:101
void sendOut()
Definition: coredbbackend_p.h:118
Definition: coredbbackend_p.h:39
void sendToWatch(const SearchChangeset &changeset)
Definition: coredbbackend_p.h:91
ChangesetContainer< SearchChangeset > searchChangesetContainer
Definition: coredbbackend_p.h:142
ChangesetContainer< AlbumRootChangeset > albumRootChangesetContainer
Definition: coredbbackend_p.h:141
CoreDbBackendPrivate(CoreDbBackend *const backend)
Definition: coredbbackend_p.h:42
ChangesetContainer< ImageChangeset > imageChangesetContainer
Definition: coredbbackend_p.h:136
void sendToWatch(const AlbumChangeset &changeset)
Definition: coredbbackend_p.h:76
ChangesetContainer< ImageTagChangeset > imageTagChangesetContainer
Definition: coredbbackend_p.h:137
void sendToWatch(const AlbumRootChangeset &changeset)
Definition: coredbbackend_p.h:86
ChangesetContainer< AlbumChangeset > albumChangesetContainer
Definition: coredbbackend_p.h:139
ChangesetContainer< CollectionImageChangeset > collectionImageChangesetContainer
Definition: coredbbackend_p.h:138
void sendToWatch(const ImageTagChangeset &changeset)
Definition: coredbbackend_p.h:66
void sendToWatch(const CollectionImageChangeset &changeset)
Definition: coredbbackend_p.h:71
void sendToWatch(const TagChangeset &changeset)
Definition: coredbbackend_p.h:81
CoreDbWatch * watch
Definition: coredbbackend_p.h:57
void transactionFinished() override
Definition: coredbbackend_p.h:146
void sendToWatch(const ImageChangeset &changeset)
Definition: coredbbackend_p.h:61
ChangesetContainer< TagChangeset > tagChangesetContainer
Definition: coredbbackend_p.h:140
Definition: coredbbackend.h:42
Definition: coredbwatch.h:44
void sendSearchChange(const SearchChangeset &changeset)
Definition: coredbwatch.cpp:373
void sendImageTagChange(const ImageTagChangeset &changeset)
Definition: coredbwatch.cpp:313
void sendCollectionImageChange(const CollectionImageChangeset &changeset)
Definition: coredbwatch.cpp:325
void sendAlbumChange(const AlbumChangeset &changeset)
Definition: coredbwatch.cpp:337
void sendAlbumRootChange(const AlbumRootChangeset &changeset)
Definition: coredbwatch.cpp:361
void sendImageChange(const ImageChangeset &changeset)
Definition: coredbwatch.cpp:297
void sendTagChange(const TagChangeset &changeset)
Definition: coredbwatch.cpp:349
Definition: coredbchangesets.h:48
Definition: coredbchangesets.h:80
Definition: coredbchangesets.h:372
Definition: coredbchangesets.h:298
Definition: piwigotalker.h:48
#define T
Definition: datefolderview.cpp:43