libquentier  0.5.0
The library for rich desktop clients of Evernote service
LocalStorageCacheManager.h
1 /*
2  * Copyright 2016-2020 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 #ifndef LIB_QUENTIER_LOCAL_STORAGE_LOCAL_STORAGE_CACHE_MANAGER_H
20 #define LIB_QUENTIER_LOCAL_STORAGE_LOCAL_STORAGE_CACHE_MANAGER_H
21 
22 #include <quentier/utility/Printable.h>
23 
24 #include <memory>
25 
26 namespace quentier {
27 
28 QT_FORWARD_DECLARE_CLASS(LinkedNotebook)
29 QT_FORWARD_DECLARE_CLASS(Note)
30 QT_FORWARD_DECLARE_CLASS(Notebook)
31 QT_FORWARD_DECLARE_CLASS(Resource)
32 QT_FORWARD_DECLARE_CLASS(SavedSearch)
33 QT_FORWARD_DECLARE_CLASS(Tag)
34 
35 QT_FORWARD_DECLARE_CLASS(ILocalStorageCacheExpiryChecker)
36 
37 QT_FORWARD_DECLARE_CLASS(LocalStorageCacheManagerPrivate)
38 class QUENTIER_EXPORT LocalStorageCacheManager: public Printable
39 {
40 public:
42  virtual ~LocalStorageCacheManager();
43 
44  enum WhichUid
45  {
46  LocalUid,
47  Guid
48  };
49 
50  void clear();
51  bool empty() const;
52 
53  // Notes cache
54  size_t numCachedNotes() const;
55  void cacheNote(const Note & note);
56  void expungeNote(const Note & note);
57 
58  const Note * findNote(
59  const QString & uid, const WhichUid whichUid) const;
60 
61  void clearAllNotes();
62 
63  // Resources cache
64  size_t numCachedResources() const;
65  void cacheResource(const Resource & resource);
66  void expungeResource(const Resource & resource);
67 
68  const Resource * findResource(
69  const QString & id, const WhichUid whichUid) const;
70 
71  void clearAllResources();
72 
73  // Notebooks cache
74  size_t numCachedNotebooks() const;
75  void cacheNotebook(const Notebook & notebook);
76  void expungeNotebook(const Notebook & notebook);
77 
78  const Notebook * findNotebook(
79  const QString & uid, const WhichUid whichUid) const;
80 
81  const Notebook * findNotebookByName(const QString & name) const;
82  void clearAllNotebooks();
83 
84  // Tags cache
85  size_t numCachedTags() const;
86  void cacheTag(const Tag & tag);
87  void expungeTag(const Tag & tag);
88  const Tag * findTag(const QString & uid, const WhichUid whichUid) const;
89  const Tag * findTagByName(const QString & name) const;
90  void clearAllTags();
91 
92  // Linked notebooks cache
93  size_t numCachedLinkedNotebooks() const;
94  void cacheLinkedNotebook(const LinkedNotebook & linkedNotebook);
95  void expungeLinkedNotebook(const LinkedNotebook & linkedNotebook);
96  const LinkedNotebook * findLinkedNotebook(const QString & guid) const;
97  void clearAllLinkedNotebooks();
98 
99  // Saved searches cache
100  size_t numCachedSavedSearches() const;
101  void cacheSavedSearch(const SavedSearch & savedSearch);
102  void expungeSavedSearch(const SavedSearch & savedSearch);
103 
104  const SavedSearch * findSavedSearch(
105  const QString & uid, const WhichUid whichUid) const;
106 
107  const SavedSearch * findSavedSearchByName(const QString & name) const;
108  void clearAllSavedSearches();
109 
110  void installCacheExpiryFunction(
111  const ILocalStorageCacheExpiryChecker & checker);
112 
113  virtual QTextStream & print(QTextStream & strm) const override;
114 
115 private:
116  Q_DISABLE_COPY(LocalStorageCacheManager)
117 
118  LocalStorageCacheManagerPrivate * const d_ptr;
119  Q_DECLARE_PRIVATE(LocalStorageCacheManager)
120 };
121 
122 } // namespace quentier
123 
124 #endif // LIB_QUENTIER_LOCAL_STORAGE_LOCAL_STORAGE_CACHE_MANAGER_H
Definition: LinkedNotebook.h:32
Definition: Resource.h:29
The Printable class is the interface for Quentier's internal classes which should be able to write th...
Definition: Printable.h:38
Definition: Notebook.h:34
Definition: Tag.h:32
Definition: Note.h:34
The ILocalStorageCacheExpiryChecker class represents the interface for cache expiry checker used by L...
Definition: ILocalStorageCacheExpiryChecker.h:34
Definition: LocalStorageCacheManager.h:38
Definition: SavedSearch.h:32