From bac165a751b41cfe066420aa54f5fca6a718b9ef Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 22 Dec 2016 14:27:01 +0100 Subject: [PATCH] Added a 'const' version of cTimers::GetTimer() --- CONTRIBUTORS | 1 + HISTORY | 1 + timers.c | 11 ++++++++--- timers.h | 5 +++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 529046ad..2649262f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2927,6 +2927,7 @@ Lars Hanisch for making VDR read command line options from *.conf files in /etc/vdr/conf.d for adding a missing backslash to the help text of the SVDRP command MOVR for fixing a memory leak in case of broken Extended Event Descriptors + for adding a 'const' version of cTimers::GetTimer() Alex Lasnier for adding tuning support for ATSC devices diff --git a/HISTORY b/HISTORY index a49721ec..f1289f6d 100644 --- a/HISTORY +++ b/HISTORY @@ -8871,3 +8871,4 @@ Video Disk Recorder Revision History - Fixed truncated date/time strings in the skins on multi-byte UTF-8 systems (reported by Sergey Chernyavskiy). - Updated the Estonian OSD texts (thanks to Arthur Konovalov). +- Added a 'const' version of cTimers::GetTimer() (thanks to Lars Hanisch). diff --git a/timers.c b/timers.c index 771f66b2..e711e2e9 100644 --- a/timers.c +++ b/timers.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.c 4.5 2015/09/13 13:10:24 kls Exp $ + * $Id: timers.c 4.6 2016/12/22 14:24:44 kls Exp $ */ #include "timers.h" @@ -748,9 +748,9 @@ const cTimer *cTimers::GetById(int Id) const return NULL; } -cTimer *cTimers::GetTimer(cTimer *Timer) +const cTimer *cTimers::GetTimer(const cTimer *Timer) const { - for (cTimer *ti = First(); ti; ti = Next(ti)) { + for (const cTimer *ti = First(); ti; ti = Next(ti)) { if (!ti->Remote() && ti->Channel() == Timer->Channel() && (ti->WeekDays() && ti->WeekDays() == Timer->WeekDays() || !ti->WeekDays() && ti->Day() == Timer->Day()) && @@ -761,6 +761,11 @@ cTimer *cTimers::GetTimer(cTimer *Timer) return NULL; } +cTimer *cTimers::GetTimer(const cTimer *Timer) +{ + return (cTimer *)GetTimer(Timer); +} + const cTimer *cTimers::GetMatch(time_t t) const { static int LastPending = -1; diff --git a/timers.h b/timers.h index 4222c104..624347c6 100644 --- a/timers.h +++ b/timers.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.h 4.3 2015/09/09 10:40:24 kls Exp $ + * $Id: timers.h 4.4 2016/12/22 14:23:50 kls Exp $ */ #ifndef __TIMERS_H @@ -170,7 +170,8 @@ public: static int NewTimerId(void); const cTimer *GetById(int Id) const; cTimer *GetById(int Id) { return const_cast(static_cast(this)->GetById(Id)); }; - cTimer *GetTimer(cTimer *Timer); + const cTimer *GetTimer(const cTimer *Timer) const; + cTimer *GetTimer(const cTimer *Timer); const cTimer *GetMatch(time_t t) const; cTimer *GetMatch(time_t t) { return const_cast(static_cast(this)->GetMatch(t)); }; const cTimer *GetMatch(const cEvent *Event, eTimerMatch *Match = NULL) const;