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_CACHESTORAGEPOLICY_H 0007 #define MARBLE_CACHESTORAGEPOLICY_H 0008 0009 #include "DiscCache.h" 0010 #include "StoragePolicy.h" 0011 0012 #include <QString> 0013 0014 #include "digikam_export.h" 0015 0016 class QByteArray; 0017 0018 namespace Marble 0019 { 0020 0021 class DIGIKAM_EXPORT CacheStoragePolicy : public StoragePolicy 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 /** 0027 * Creates a new cache storage policy. 0028 * 0029 * @param cacheDirectory The directory which shall be used for the cache. 0030 */ 0031 explicit CacheStoragePolicy( const QString &cacheDirectory ); 0032 0033 /** 0034 * Destroys the cache storage policy. 0035 */ 0036 ~CacheStoragePolicy() override; 0037 0038 /** 0039 * Returns whether the @p fileName exists already. 0040 */ 0041 bool fileExists( const QString &fileName ) const override; 0042 0043 /** 0044 * Updates the @p fileName with the given @p data. 0045 */ 0046 bool updateFile( const QString &fileName, const QByteArray &data ) override; 0047 0048 /** 0049 * Clears the cache. 0050 */ 0051 void clearCache() override; 0052 0053 /** 0054 * Returns the last error message. 0055 */ 0056 QString lastErrorMessage() const override; 0057 0058 /** 0059 * Returns the data of a file. 0060 */ 0061 QByteArray data( const QString &fileName ); 0062 0063 /** 0064 * Sets the limit of the cache in @p bytes. 0065 */ 0066 void setCacheLimit( quint64 bytes ); 0067 0068 /** 0069 * Returns the limit of the cache in bytes. 0070 */ 0071 quint64 cacheLimit() const; 0072 0073 private: 0074 DiscCache m_cache; 0075 QString m_errorMsg; 0076 }; 0077 0078 } 0079 0080 #endif