Parent: [327004] (diff)

Download this file

cache.h    40 lines (33 with data), 775 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef _CACHE_H
#define _CACHE_H
class CacheEntry
{
public:
CacheEntry() {};
CacheEntry(const Song& song, time_t starttime) {
this->song = song;
this->starttime = starttime;
}
// stream serialization
friend std::ofstream& operator <<(std::ofstream& outstream, const CacheEntry& inobj);
friend std::ifstream& operator >>(std::ifstream& instream, CacheEntry& outobj);
Song getSong() const { return song; }
time_t getStartTime() const { return starttime; }
private:
Song song;
time_t starttime;
};
class CCache
{
public:
CCache() { _failtime = 0; }
void AddToCache(const Song& song, time_t starttime);
void WorkCache();
void SaveCache();
void LoadCache();
private:
time_t _failtime;
std::vector<CacheEntry*> _entries;
};
extern CCache* Cache;
#endif