• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
CacheStoragePolicy.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2007 Tobias Koenig <tokoe@kde.org>
9 //
10 
11 
12 // Own
13 #include "CacheStoragePolicy.h"
14 
15 // Qt
16 #include <QDir>
17 
18 using namespace Marble;
19 
20 CacheStoragePolicy::CacheStoragePolicy( const QString &cacheDirectory )
21  : m_cache( cacheDirectory )
22 {
23  if ( ! QDir( cacheDirectory ).exists() )
24  QDir::root().mkpath( cacheDirectory );
25 }
26 
27 CacheStoragePolicy::~CacheStoragePolicy()
28 {
29 }
30 
31 bool CacheStoragePolicy::fileExists( const QString &fileName ) const
32 {
33  return m_cache.exists( fileName );
34 }
35 
36 bool CacheStoragePolicy::updateFile( const QString &fileName, const QByteArray &data )
37 {
38  if ( !m_cache.insert( fileName, data ) ) {
39  m_errorMsg = QObject::tr("Unable to insert data into cache");
40  return false;
41  }
42 
43  return true;
44 }
45 
46 void CacheStoragePolicy::clearCache()
47 {
48  m_cache.clear();
49 }
50 
51 QString CacheStoragePolicy::lastErrorMessage() const
52 {
53  return m_errorMsg;
54 }
55 
56 QByteArray CacheStoragePolicy::data( const QString &fileName )
57 {
58  QByteArray data;
59  m_cache.find( fileName, data );
60 
61  return data;
62 }
63 
64 void CacheStoragePolicy::setCacheLimit( quint64 bytes )
65 {
66  m_cache.setCacheLimit( bytes );
67 }
68 
69 quint64 CacheStoragePolicy::cacheLimit() const
70 {
71  return m_cache.cacheLimit();
72 }
73 
74 #include "CacheStoragePolicy.moc"
Marble::CacheStoragePolicy::setCacheLimit
void setCacheLimit(quint64 bytes)
Sets the limit of the cache in bytes.
Definition: CacheStoragePolicy.cpp:64
Marble::CacheStoragePolicy::fileExists
bool fileExists(const QString &fileName) const
Returns whether the fileName exists already.
Definition: CacheStoragePolicy.cpp:31
Marble::CacheStoragePolicy::CacheStoragePolicy
CacheStoragePolicy(const QString &cacheDirectory)
Creates a new cache storage policy.
Definition: CacheStoragePolicy.cpp:20
QByteArray
Marble::CacheStoragePolicy::lastErrorMessage
QString lastErrorMessage() const
Returns the last error message.
Definition: CacheStoragePolicy.cpp:51
Marble::DiscCache::cacheLimit
quint64 cacheLimit() const
Definition: DiscCache.cpp:67
QDir::root
QDir root()
Marble::CacheStoragePolicy::cacheLimit
quint64 cacheLimit() const
Returns the limit of the cache in bytes.
Definition: CacheStoragePolicy.cpp:69
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
CacheStoragePolicy.h
QString
QDir
Marble::DiscCache::setCacheLimit
void setCacheLimit(quint64 n)
Definition: DiscCache.cpp:159
Marble::DiscCache::find
bool find(const QString &key, QByteArray &data)
Definition: DiscCache.cpp:98
Marble::CacheStoragePolicy::clearCache
void clearCache()
Clears the cache.
Definition: CacheStoragePolicy.cpp:46
Marble::DiscCache::clear
void clear()
Definition: DiscCache.cpp:72
Marble::CacheStoragePolicy::updateFile
bool updateFile(const QString &fileName, const QByteArray &data)
Updates the fileName with the given data.
Definition: CacheStoragePolicy.cpp:36
Marble::DiscCache::exists
bool exists(const QString &key) const
Definition: DiscCache.cpp:93
Marble::DiscCache::insert
bool insert(const QString &key, const QByteArray &data)
Definition: DiscCache.cpp:116
Marble::CacheStoragePolicy::data
QByteArray data(const QString &fileName)
Returns the data of a file.
Definition: CacheStoragePolicy.cpp:56
Marble::CacheStoragePolicy::~CacheStoragePolicy
~CacheStoragePolicy()
Destroys the cache storage policy.
Definition: CacheStoragePolicy.cpp:27
QDir::mkpath
bool mkpath(const QString &dirPath) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal