Akonadi

server/storage/collectionstatistics.h
1 /*
2  * Copyright (C) 2014 Daniel Vrátil <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #ifndef AKONADI_SERVER_COLLECTIONSTATISTICS_H
21 #define AKONADI_SERVER_COLLECTIONSTATISTICS_H
22 
23 class QMutex;
24 
25 #include <QHash>
26 #include <QMutex>
27 
28 namespace Akonadi
29 {
30 namespace Server
31 {
32 
33 class QueryBuilder;
34 class Collection;
35 
48 {
49 public:
50  struct Statistics {
51  qint64 count;
52  qint64 size;
53  qint64 read;
54  };
55 
56  explicit CollectionStatistics(bool prefetch = true);
57  virtual ~CollectionStatistics() = default;
58 
59  const Statistics statistics(const Collection &col);
60 
61  void itemAdded(const Collection &col, qint64 size, bool seen);
62  void itemsSeenChanged(const Collection &col, qint64 seenCount);
63 
64  void invalidateCollection(const Collection &col);
65 
66  void expireCache();
67 
68 protected:
69  QueryBuilder prepareGenericQuery();
70 
71  virtual Statistics calculateCollectionStatistics(const Collection &col);
72 
73  QMutex mCacheLock;
75 };
76 
77 } // namespace Server
78 } // namespace Akonadi
79 
80 #endif // AKONADI_SERVER_COLLECTIONSTATISTICS_H
Helper integration between Akonadi and Qt.
Provides cache for collection statistics.
Helper class to construct arbitrary SQL queries.
Definition: querybuilder.h:45
Representation of a record in the Collection table.
Definition: entities.h:451
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:43:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.