summaryrefslogtreecommitdiff
path: root/recordings.h
blob: 748b832ade3cbfbfd460e1508b12b28c86fbf095 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef VDR_LIVE_RECORDINGS_H
#define VDR_LIVE_RECORDINGS_H

#include <ctime>
#include <map>
#include <boost/shared_ptr.hpp>
#include <vdr/recording.h>

namespace vdrlive {

	using namespace boost;
	using namespace std;

	class RecordingsTree
	{
		friend RecordingsTree& LiveRecordingsTree();

		public:

			class RecordingsItem;

			typedef shared_ptr< RecordingsItem > RecordingsItemPtr;
			typedef map< string, RecordingsItemPtr > Map;

			class RecordingsItem
			{
				friend class RecordingsTree;

				public:
					virtual ~RecordingsItem();

					virtual time_t StartTime() const = 0;
					virtual bool IsDir() const = 0;
					virtual const char* Name() const = 0;

				protected:
					RecordingsItem();

				private:
					Map m_entries;
			};

			class RecordingsItemDir : public RecordingsItem
			{
				public:
					RecordingsItemDir();
					RecordingsItemDir(const string& name, int level);

					virtual ~RecordingsItemDir();

					virtual time_t StartTime() const { return 0; }
					virtual bool IsDir() const { return true; }
					virtual const char* Name() const { return m_name.c_str(); }

				private:
					string m_name;
					int m_level;
			};

			class RecordingsItemRec : public RecordingsItem
			{
				public:
					RecordingsItemRec(cRecording* recording);

					virtual ~RecordingsItemRec();

					virtual time_t StartTime() const;
					virtual bool IsDir() const { return false; }
					virtual const char* Name() const { return m_recording->Name(); }

				private:
					cRecording *m_recording;
			};

			RecordingsTree();

			virtual ~RecordingsTree();

			Map::iterator begin() { return m_root->m_entries.begin(); }
			Map::iterator end() { return m_root->m_entries.end(); }

			int MaxLevel() const { return m_maxLevel; }

		private:
			int m_maxLevel;
			RecordingsItemPtr m_root;
			cThreadLock m_recordingsLock;

			static RecordingsTree* globalInstance;
	};

	RecordingsTree& LiveRecordingsTree();
} // namespace vdrlive

#endif // VDR_LIVE_RECORDINGS_H