annotate data/fileio/CachedFile.h @ 514:6acdddf6f99e

* fixes to improve the utility of the CSV feature writer
author Chris Cannam
date Wed, 10 Dec 2008 13:21:10 +0000
parents a82645e788fc
children e340b2fb9471
rev   line source
Chris@465 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@465 2
Chris@465 3 /*
Chris@465 4 Sonic Visualiser
Chris@465 5 An audio file viewer and annotation editor.
Chris@465 6 Centre for Digital Music, Queen Mary, University of London.
Chris@465 7 This file copyright 2008 QMUL.
Chris@465 8
Chris@465 9 This program is free software; you can redistribute it and/or
Chris@465 10 modify it under the terms of the GNU General Public License as
Chris@465 11 published by the Free Software Foundation; either version 2 of the
Chris@465 12 License, or (at your option) any later version. See the file
Chris@465 13 COPYING included with this distribution for more information.
Chris@465 14 */
Chris@465 15
Chris@465 16 #ifndef _CACHED_FILE_H_
Chris@465 17 #define _CACHED_FILE_H_
Chris@465 18
Chris@465 19 #include <QString>
Chris@465 20 #include <QUrl>
Chris@465 21 #include <QDateTime>
Chris@481 22 #include <map>
Chris@465 23
Chris@465 24 class ProgressReporter;
Chris@465 25
Chris@465 26 class CachedFile
Chris@465 27 {
Chris@465 28 public:
Chris@467 29 CachedFile(QString fileOrUrl, ProgressReporter *reporter = 0);
Chris@465 30 CachedFile(QUrl url, ProgressReporter *reporter = 0);
Chris@465 31
Chris@465 32 virtual ~CachedFile();
Chris@465 33
Chris@465 34 bool isOK() const;
Chris@465 35
Chris@465 36 QString getLocalFilename() const;
Chris@465 37
Chris@465 38 protected:
Chris@468 39 QString m_origin;
Chris@465 40 QString m_localFilename;
Chris@466 41 ProgressReporter *m_reporter;
Chris@465 42 bool m_ok;
Chris@465 43
Chris@467 44 void check();
Chris@465 45 bool retrieve();
Chris@465 46
Chris@465 47 QDateTime getLastRetrieval();
Chris@465 48 void updateLastRetrieval(bool successful);
Chris@465 49
Chris@465 50 static QString getCacheDirectory();
Chris@465 51 static QString getLocalFilenameFor(QUrl url);
Chris@481 52
Chris@481 53 typedef std::map<QString, QString> OriginLocalFilenameMap;
Chris@481 54 static OriginLocalFilenameMap m_knownGoodCaches;
Chris@465 55 };
Chris@465 56
Chris@465 57 #endif