summaryrefslogtreecommitdiff
path: root/timers.h
blob: 339ead463711d50d191cd52ae975542d5b89d0d5 (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
#ifndef VDR_LIVE_TIMERS_H
#define VDR_LIVE_TIMERS_H

#include <list>
#include <string>
#include <vdr/timers.h>
#include <vdr/thread.h>
#include "live.h"

namespace vdrlive {

class Plugin;

class SortedTimersInterface: public std::list< cTimer >
{
public:
	virtual ~SortedTimersInterface() {}

	virtual std::string GetTimerId( cTimer const& timer ) = 0;
};

class SortedTimers: public SortedTimersInterface
{
	friend class TimerManager;

public:
	virtual std::string GetTimerId( cTimer const& timer );
	
private:
	SortedTimers();
	SortedTimers( SortedTimers const& );

	int m_state;
	int m_refs;
	
	void ReloadTimers( bool initial = false );
};

class TimerManager: public cMutex
{
	friend TimerManager& Plugin::GetLiveTimerManager();

public:
	SortedTimersInterface& GetTimers() { return m_timers; }

	// may only be called from Plugin::MainThreadHook
	void DoPendingWork();

private:
	TimerManager();
	TimerManager( TimerManager const& );

	SortedTimers m_timers;
};

inline TimerManager& LiveTimerManager()
{
	return LivePlugin().GetLiveTimerManager();
}

} // namespace vdrlive

#endif // VDR_LIVE_TIMERS_H