mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
The new class cSortedTimers can be used to quickly get a list of all timers, sorted by their start time
This commit is contained in:
parent
7548639021
commit
4e57f40096
2
HISTORY
2
HISTORY
@ -7118,3 +7118,5 @@ Video Disk Recorder Revision History
|
|||||||
- Fixed resetting CAMs (thanks to Marco Skambraks).
|
- Fixed resetting CAMs (thanks to Marco Skambraks).
|
||||||
- The new function RgbShade() (include osd.h) can be used to generate a brighter or
|
- The new function RgbShade() (include osd.h) can be used to generate a brighter or
|
||||||
darker version of a given color.
|
darker version of a given color.
|
||||||
|
- The new class cSortedTimers can be used to quickly get a list of all timers, sorted
|
||||||
|
by their start time.
|
||||||
|
19
timers.c
19
timers.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: timers.c 2.8 2012/02/27 09:38:41 kls Exp $
|
* $Id: timers.c 2.9 2012/06/02 12:10:00 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
@ -142,7 +142,7 @@ cTimer& cTimer::operator= (const cTimer &Timer)
|
|||||||
|
|
||||||
int cTimer::Compare(const cListObject &ListObject) const
|
int cTimer::Compare(const cListObject &ListObject) const
|
||||||
{
|
{
|
||||||
cTimer *ti = (cTimer *)&ListObject;
|
const cTimer *ti = (const cTimer *)&ListObject;
|
||||||
time_t t1 = StartTime();
|
time_t t1 = StartTime();
|
||||||
time_t t2 = ti->StartTime();
|
time_t t2 = ti->StartTime();
|
||||||
int r = t1 - t2;
|
int r = t1 - t2;
|
||||||
@ -820,3 +820,18 @@ void cTimers::DeleteExpired(void)
|
|||||||
}
|
}
|
||||||
lastDeleteExpired = time(NULL);
|
lastDeleteExpired = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- cSortedTimers ---------------------------------------------------------
|
||||||
|
|
||||||
|
static int CompareTimers(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return (*(const cTimer **)a)->Compare(**(const cTimer **)b);
|
||||||
|
}
|
||||||
|
|
||||||
|
cSortedTimers::cSortedTimers(void)
|
||||||
|
:cVector(Timers.Count())
|
||||||
|
{
|
||||||
|
for (const cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer))
|
||||||
|
Append(Timer);
|
||||||
|
Sort(CompareTimers);
|
||||||
|
}
|
||||||
|
7
timers.h
7
timers.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: timers.h 2.3 2012/02/20 15:52:57 kls Exp $
|
* $Id: timers.h 2.4 2012/06/02 12:10:00 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __TIMERS_H
|
#ifndef __TIMERS_H
|
||||||
@ -135,4 +135,9 @@ public:
|
|||||||
|
|
||||||
extern cTimers Timers;
|
extern cTimers Timers;
|
||||||
|
|
||||||
|
class cSortedTimers : public cVector<const cTimer *> {
|
||||||
|
public:
|
||||||
|
cSortedTimers(void);
|
||||||
|
};
|
||||||
|
|
||||||
#endif //__TIMERS_H
|
#endif //__TIMERS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user