File: cache.h

package info (click to toggle)
mpdas 0.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 188 kB
  • sloc: cpp: 1,455; makefile: 34
file content (39 lines) | stat: -rw-r--r-- 775 bytes parent folder | download
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