Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
[kdemultimedia.git] / juk / cache.h
blobf06c4ee66b015878386a295c5416a8235bed75b6
1 /***************************************************************************
2 begin : Sat Sep 7 2002
3 copyright : (C) 2002 - 2004 by Scott Wheeler
4 email : wheeler@kde.org
5 ***************************************************************************/
7 /***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
16 #ifndef CACHE_H
17 #define CACHE_H
19 #include <QDataStream>
21 #include "stringhash.h"
23 class Tag;
24 class Playlist;
25 class PlaylistCollection;
27 template<class T>
28 class QList;
30 typedef QList<Playlist *> PlaylistList;
32 class Cache : public FileHandleHash
34 public:
35 static Cache *instance();
36 void save();
38 static void loadPlaylists(PlaylistCollection *collection);
39 static void savePlaylists(const PlaylistList &playlists);
41 static bool cacheFileExists();
43 protected:
44 Cache();
45 void load();
47 private:
48 static const int m_currentVersion = 1;
51 /**
52 * A simple QDataStream subclass that has an extra field to indicate the cache
53 * version.
56 class CacheDataStream : public QDataStream
58 public:
59 CacheDataStream(QIODevice *d) : QDataStream(d), m_cacheVersion(0) {}
60 CacheDataStream(QByteArray &a, int mode) : QDataStream(&a, mode), m_cacheVersion(0) {}
62 virtual ~CacheDataStream() {}
64 int cacheVersion() const { return m_cacheVersion; }
65 void setCacheVersion(int v) { m_cacheVersion = v; }
67 private:
68 int m_cacheVersion;
71 #endif
73 // vim: set et sw=4 tw=0 sta: