#include <CachedFile.h>

Collaboration diagram for CachedFile:
Collaboration graph

Public Member Functions

 CachedFile (QString fileOrUrl, ProgressReporter *reporter=0, QString preferredContentType="")
 
 CachedFile (QUrl url, ProgressReporter *reporter=0, QString preferredContentType="")
 
virtual ~CachedFile ()
 
bool isOK () const
 
QString getLocalFilename () const
 

Protected Types

typedef std::map< QString, QString > OriginLocalFilenameMap
 

Protected Member Functions

void checkFile ()
 
bool retrieve ()
 
QDateTime getLastRetrieval ()
 
void updateLastRetrieval (bool successful)
 

Static Protected Member Functions

static QString getCacheDirectory ()
 
static QString getLocalFilenameFor (QUrl url)
 

Protected Attributes

QString m_origin
 
QString m_localFilename
 
QString m_preferredContentType
 
ProgressReporterm_reporter
 
bool m_ok
 

Static Protected Attributes

static OriginLocalFilenameMap m_knownGoodCaches
 

Detailed Description

Definition at line 26 of file CachedFile.h.

Member Typedef Documentation

typedef std::map<QString, QString> CachedFile::OriginLocalFilenameMap
protected

Definition at line 58 of file CachedFile.h.

Constructor & Destructor Documentation

CachedFile::CachedFile ( QString  fileOrUrl,
ProgressReporter reporter = 0,
QString  preferredContentType = "" 
)

Definition at line 71 of file CachedFile.cpp.

References checkFile(), and SVDEBUG.

CachedFile::CachedFile ( QUrl  url,
ProgressReporter reporter = 0,
QString  preferredContentType = "" 
)

Definition at line 86 of file CachedFile.cpp.

References checkFile(), and SVDEBUG.

CachedFile::~CachedFile ( )
virtual

Definition at line 101 of file CachedFile.cpp.

Member Function Documentation

bool CachedFile::isOK ( ) const

Definition at line 106 of file CachedFile.cpp.

References m_ok.

Referenced by PluginRDFIndexer::indexConfiguredURLs(), and PluginRDFIndexer::pullURL().

QString CachedFile::getLocalFilename ( ) const

Definition at line 112 of file CachedFile.cpp.

References m_localFilename.

Referenced by PluginRDFIndexer::indexConfiguredURLs(), and PluginRDFIndexer::pullURL().

void CachedFile::checkFile ( )
protected

!! n.b. obvious race condition here if different CachedFile

!!

!! but we do want an additional last-attempted

Definition at line 118 of file CachedFile.cpp.

References getLastRetrieval(), getLocalFilenameFor(), m_knownGoodCaches, m_localFilename, m_ok, m_origin, retrieve(), SVCERR, SVDEBUG, and updateLastRetrieval().

Referenced by CachedFile().

bool CachedFile::retrieve ( )
protected

!! need to work by retrieving the file to another name, and !! then "atomically" moving it to its proper place (I'm not !! sure we can do an atomic move to replace an existing file !! using Qt classes, but a plain delete then copy is probably !! good enough)

!! This is not ideal, could leave us with nothing (old file !! removed, new file not able to be copied in because e.g. no !! disk space left)

Definition at line 183 of file CachedFile.cpp.

References FileSource::getLocalFilename(), FileSource::isAvailable(), FileSource::isOK(), m_localFilename, m_origin, m_preferredContentType, m_reporter, SVCERR, SVDEBUG, and FileSource::waitForData().

Referenced by checkFile().

QDateTime CachedFile::getLastRetrieval ( )
protected

Definition at line 235 of file CachedFile.cpp.

References m_localFilename.

Referenced by checkFile().

void CachedFile::updateLastRetrieval ( bool  successful)
protected

!! note !successful does not mean "we failed to update the !! file" (and so it remains the same as before); it means "the !! file is not there at all"

Definition at line 250 of file CachedFile.cpp.

References m_localFilename.

Referenced by checkFile().

QString CachedFile::getCacheDirectory ( )
staticprotected

Definition at line 54 of file CachedFile.cpp.

References TempDirectory::getContainingPath(), and TempDirectory::getInstance().

Referenced by getLocalFilenameFor().

QString CachedFile::getLocalFilenameFor ( QUrl  url)
staticprotected

Definition at line 39 of file CachedFile.cpp.

References getCacheDirectory().

Referenced by checkFile().

Member Data Documentation

QString CachedFile::m_origin
protected

Definition at line 43 of file CachedFile.h.

Referenced by checkFile(), and retrieve().

QString CachedFile::m_localFilename
protected
QString CachedFile::m_preferredContentType
protected

Definition at line 45 of file CachedFile.h.

Referenced by retrieve().

ProgressReporter* CachedFile::m_reporter
protected

Definition at line 46 of file CachedFile.h.

Referenced by retrieve().

bool CachedFile::m_ok
protected

Definition at line 47 of file CachedFile.h.

Referenced by checkFile(), and isOK().

CachedFile::OriginLocalFilenameMap CachedFile::m_knownGoodCaches
staticprotected

Definition at line 59 of file CachedFile.h.

Referenced by checkFile().


The documentation for this class was generated from the following files: