libquentier  0.8.0
The library for rich desktop clients of Evernote service
ISyncConflictResolver.h
1 /*
2  * Copyright 2021-2024 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier 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 Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <quentier/utility/Linkage.h>
22 
23 #include <qevercloud/types/Note.h>
24 #include <qevercloud/types/Notebook.h>
25 #include <qevercloud/types/SavedSearch.h>
26 #include <qevercloud/types/Tag.h>
27 
28 #include <QFuture>
29 
30 #include <variant>
31 
32 class QDebug;
33 class QTextStream;
34 
35 namespace quentier::synchronization {
36 
41 class QUENTIER_EXPORT ISyncConflictResolver
42 {
43 public:
48  struct QUENTIER_EXPORT ConflictResolution
49  {
54  struct QUENTIER_EXPORT UseTheirs
55  {};
56 
61  struct QUENTIER_EXPORT UseMine
62  {};
63 
69  struct QUENTIER_EXPORT IgnoreMine
70  {};
71 
80  template <class T>
81  struct MoveMine
82  {
83  using value_type = T;
84 
88  T mine;
89  };
90  };
91 
92  using NotebookConflictResolution = std::variant<
96 
97  using NoteConflictResolution = std::variant<
101 
102  using SavedSearchConflictResolution = std::variant<
106 
107  using TagConflictResolution = std::variant<
111 
112 public:
113  virtual ~ISyncConflictResolver() noexcept;
114 
115  [[nodiscard]] virtual QFuture<NotebookConflictResolution>
116  resolveNotebookConflict(
117  qevercloud::Notebook theirs, qevercloud::Notebook mine) = 0;
118 
119  [[nodiscard]] virtual QFuture<NoteConflictResolution> resolveNoteConflict(
120  qevercloud::Note theirs, qevercloud::Note mine) = 0;
121 
122  [[nodiscard]] virtual QFuture<SavedSearchConflictResolution>
123  resolveSavedSearchConflict(
124  qevercloud::SavedSearch theirs, qevercloud::SavedSearch mine) = 0;
125 
126  [[nodiscard]] virtual QFuture<TagConflictResolution> resolveTagConflict(
127  qevercloud::Tag theirs, qevercloud::Tag mine) = 0;
128 };
129 
130 QUENTIER_EXPORT QTextStream & operator<<(
131  QTextStream & strm,
132  const ISyncConflictResolver::NotebookConflictResolution & resolution);
133 
134 QUENTIER_EXPORT QDebug & operator<<(
135  QDebug & dbg,
136  const ISyncConflictResolver::NotebookConflictResolution & resolution);
137 
138 QUENTIER_EXPORT QTextStream & operator<<(
139  QTextStream & strm,
140  const ISyncConflictResolver::NoteConflictResolution & resolution);
141 
142 QUENTIER_EXPORT QDebug & operator<<(
143  QDebug & dbg,
144  const ISyncConflictResolver::NoteConflictResolution & resolution);
145 
146 QUENTIER_EXPORT QTextStream & operator<<(
147  QTextStream & strm,
148  const ISyncConflictResolver::SavedSearchConflictResolution & resolution);
149 
150 QUENTIER_EXPORT QDebug & operator<<(
151  QDebug & dbg,
152  const ISyncConflictResolver::SavedSearchConflictResolution & resolution);
153 
154 QUENTIER_EXPORT QTextStream & operator<<(
155  QTextStream & strm,
156  const ISyncConflictResolver::TagConflictResolution & resolution);
157 
158 QUENTIER_EXPORT QDebug & operator<<(
159  QDebug & dbg,
160  const ISyncConflictResolver::TagConflictResolution & resolution);
161 
162 } // namespace quentier::synchronization
The IgnoreMine conflict resolution means "use theirs version and ignore mine version as it doesn&#39;t re...
Definition: ISyncConflictResolver.h:69
Definition: synchronization/Factory.h:35
The MoveMine conflict resolution means "before using theirs version change mine version as specified"...
Definition: ISyncConflictResolver.h:81
The ConflictResolution struct is a namespace inside which several other structs determining actual co...
Definition: ISyncConflictResolver.h:48
The ISyncConflictResolver interface provides methods used to resolve conflicts between local and remo...
Definition: ISyncConflictResolver.h:41
The UseTheirs conflict resolution means "override mine version with theirs version".
Definition: ISyncConflictResolver.h:54
The UseMine conflict resolution means "override theirs version with mine version".
Definition: ISyncConflictResolver.h:61