libquentier  0.4.0
The library for rich desktop clients of Evernote service
LocalStorageCacheManager.h
1 /*
2  * Copyright 2016 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 #include <QScopedPointer>
24 
25 namespace quentier {
26 
27 QT_FORWARD_DECLARE_CLASS(Note)
28 QT_FORWARD_DECLARE_CLASS(Notebook)
29 QT_FORWARD_DECLARE_CLASS(Tag)
30 QT_FORWARD_DECLARE_CLASS(LinkedNotebook)
31 QT_FORWARD_DECLARE_CLASS(SavedSearch)
32 
33 QT_FORWARD_DECLARE_CLASS(ILocalStorageCacheExpiryChecker)
34 
35 QT_FORWARD_DECLARE_CLASS(LocalStorageCacheManagerPrivate)
36 class QUENTIER_EXPORT LocalStorageCacheManager: public Printable
37 {
38 public:
40  virtual ~LocalStorageCacheManager();
41 
42  enum WhichUid
43  {
44  LocalUid,
45  Guid
46  };
47 
48  void clear();
49  bool empty() const;
50 
51  // Notes cache
52  size_t numCachedNotes() const;
53  void cacheNote(const Note & note);
54  void expungeNote(const Note & note);
55  const Note * findNote(const QString & guid, const WhichUid wg) const;
56 
57  // Notebooks cache
58  size_t numCachedNotebooks() const;
59  void cacheNotebook(const Notebook & notebook);
60  void expungeNotebook(const Notebook & notebook);
61  const Notebook * findNotebook(const QString & guid, const WhichUid wg) const;
62  const Notebook * findNotebookByName(const QString & name) const;
63 
64  // Tags cache
65  size_t numCachedTags() const;
66  void cacheTag(const Tag & tag);
67  void expungeTag(const Tag & tag);
68  const Tag * findTag(const QString & guid, const WhichUid wg) const;
69  const Tag * findTagByName(const QString & name) const;
70 
71  // Linked notebooks cache
72  size_t numCachedLinkedNotebooks() const;
73  void cacheLinkedNotebook(const LinkedNotebook & linkedNotebook);
74  void expungeLinkedNotebook(const LinkedNotebook & linkedNotebook);
75  const LinkedNotebook * findLinkedNotebook(const QString & guid) const;
76 
77  // Saved searches cache
78  size_t numCachedSavedSearches() const;
79  void cacheSavedSearch(const SavedSearch & savedSearch);
80  void expungeSavedSearch(const SavedSearch & savedSearch);
81  const SavedSearch * findSavedSearch(const QString & guid, const WhichUid wg) const;
82  const SavedSearch * findSavedSearchByName(const QString & name) const;
83 
84  void installCacheExpiryFunction(const ILocalStorageCacheExpiryChecker & checker);
85 
86  virtual QTextStream & print(QTextStream & strm) const Q_DECL_OVERRIDE;
87 
88 private:
89  Q_DISABLE_COPY(LocalStorageCacheManager)
90 
91  LocalStorageCacheManagerPrivate * d_ptr;
92  Q_DECLARE_PRIVATE(LocalStorageCacheManager)
93 };
94 
95 } // namespace quentier
96 
97 #endif // LIB_QUENTIER_LOCAL_STORAGE_LOCAL_STORAGE_CACHE_MANAGER_H
Definition: LinkedNotebook.h:36
The Printable class is the interface for Quentier's internal classes which should be able to write th...
Definition: Printable.h:54
Definition: Notebook.h:38
Definition: Tag.h:36
Definition: Note.h:38
The ILocalStorageCacheExpiryChecker class represents the interface for cache expiry checker used by L...
Definition: ILocalStorageCacheExpiryChecker.h:33
Definition: LocalStorageCacheManager.h:36
Definition: SavedSearch.h:36