forked from vdr-projects/vdr-plugin-tvscraper
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsEvent.h
67 lines (62 loc) · 2.16 KB
/
sEvent.h
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
#ifndef __TVSCRAPER_SEVENT_H
#define __TVSCRAPER_SEVENT_H
#include <string>
#include "tools/stringhelpers.h"
class cStaticEvent {
public:
void set_from_event(const cEvent *event) {
m_eventID = event->EventID();
m_startTime = event->StartTime();
m_endTime = event->EndTime();
m_vps = event->Vps();
m_duration = event->Duration();
m_channelID = event->ChannelID();
m_title = cSv(event->Title());
m_shortText = cSv(event->ShortText());
m_description = cSv(event->Description());
}
tEventID EventID() const { return m_eventID; }
time_t StartTime() const { return m_startTime; }
time_t EndTime() const { return m_endTime; }
time_t Vps() const { return m_vps; }
int Duration() const { return m_duration; }
const tChannelID ChannelID() const { return m_channelID; }
const char *Title() const { return m_title.c_str(); }
const char *ShortText() const { return m_shortText.c_str(); }
const char *Description() const { return m_description.c_str(); }
template<class changeEventF>
bool ChangeEvent(changeEventF changeEventFunction) {
// return false if no event was found
// return true if event was found and changeEventFunction was called
LOCK_SCHEDULES_WRITE;
cSchedule *pSchedule = const_cast<cSchedule *>(Schedules->GetSchedule(m_channelID));
if (!pSchedule) return false;
#if APIVERSNUM >= 20502
cEvent *event = const_cast<cEvent *>(pSchedule->GetEventById(m_eventID));
#else
cEvent *event = const_cast<cEvent *>(pSchedule->GetEvent(m_eventID));
#endif
if (!event) return false;
changeEventFunction(event);
return true;
}
void SetShortText(const char *ShortText) {
if (ChangeEvent([ShortText](cEvent *event) { event->SetShortText(ShortText); }))
m_shortText = cSv(ShortText);
}
void SetDescription(const char *Description) {
if (ChangeEvent([Description](cEvent *event) { event->SetDescription(Description); }))
m_description = cSv(Description);
}
private:
tEventID m_eventID;
time_t m_startTime;
time_t m_endTime;
time_t m_vps;
int m_duration;
tChannelID m_channelID;
std::string m_title;
std::string m_shortText;
std::string m_description;
};
#endif //__TVSCRAPER_SEVENT_H