File indexing completed on 2025-01-05 03:59:34
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org> 0004 // 0005 0006 #ifndef MARBLE_DISCCACHE_H 0007 #define MARBLE_DISCCACHE_H 0008 0009 #include <QDateTime> 0010 #include <QMap> 0011 #include <QPair> 0012 #include <QString> 0013 0014 class QByteArray; 0015 0016 namespace Marble 0017 { 0018 0019 class DiscCache 0020 { 0021 public: 0022 explicit DiscCache( const QString &cacheDirectory ); 0023 ~DiscCache(); 0024 0025 quint64 cacheLimit() const; 0026 void clear(); 0027 bool exists( const QString &key ) const; 0028 bool find( const QString &key, QByteArray &data ); 0029 bool insert( const QString &key, const QByteArray &data ); 0030 void remove( const QString &key ); 0031 void setCacheLimit( quint64 n ); 0032 0033 private: 0034 QString keyToFileName( const QString& ) const; 0035 void cleanup(); 0036 0037 QString m_CacheDirectory; 0038 quint64 m_CacheLimit; 0039 quint64 m_CurrentCacheSize; 0040 0041 typedef QPair<QDateTime, quint64> Entry; 0042 QMap<QString, Entry> m_Entries; 0043 }; 0044 0045 } 0046 0047 #endif