summaryrefslogtreecommitdiff
path: root/cache.h
blob: 75023ea825764373a675c968a9ecb50276cbc3f5 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * cache.h
 */

#ifndef __CACHE_H
#define __CACHE_H

#include "xml-cache.h"
#include "trackinfo.h"
#include "column.h"

#include <vdr/thread.h>

#include <list>
#include <string>

#define NOTHING 0
#define LOAD 1
#define REBUILD 2


class cCache : public cThread {
private:
        bool active;
        int what_to_do;

        std::list<cTrackInfo> tracklist;
	std::list<cTrackInfo>::iterator track;

        cXmlCache xmlcache;

	static const cColumn *sort_order;

        static bool sort_tracklist(const cTrackInfo & lhs,
                const cTrackInfo &rhs);
protected:
        virtual void Action(void);
        virtual void Activate(bool on);
public:
	cCache(void);
        ~cCache();
        void load(void) { what_to_do ^= LOAD; Activate(true); }
        void rebuild(void) { what_to_do ^= REBUILD; Activate(true); }
        bool is_rebuilding(void) { return active; }
        void sort(const cColumn *columns);

        void add_track(const cTrackInfo &trackinfo, bool add_xmlcache = true);
        int get_num_cached(void);

	const cTrackInfo *get_next_track(bool reset = false);
};

extern cCache Cache;

#endif /* __CACHE_H */