From 63a15de53d63a48c160addc7793cea5b7b76ab6c Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Wed, 3 Jan 2007 23:06:10 +0000 Subject: - added new Timers class that wraps cTimers functionality --- Makefile | 4 ++-- pages/timers.ecpp | 4 +++- timers.cpp | 18 ++++++++++++++++++ timers.h | 26 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 timers.cpp create mode 100644 timers.h diff --git a/Makefile b/Makefile index 24c7c82..97b4b87 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.19 2007/01/03 22:08:10 tadi Exp $ +# $Id: Makefile,v 1.20 2007/01/03 23:06:10 lordjaxom Exp $ # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. @@ -60,7 +60,7 @@ SUBDIRS = httpd pages css images PLUGINOBJS = $(PLUGIN).o thread.o tntconfig.o setup.o i18n.o -WEBOBJS = tools.o +WEBOBJS = tools.o timers.o WEBLIBS = pages/libpages.a \ css/libcss.a \ images/libimages.a diff --git a/pages/timers.ecpp b/pages/timers.ecpp index 65ccf6b..9b10dbe 100644 --- a/pages/timers.ecpp +++ b/pages/timers.ecpp @@ -3,6 +3,7 @@ #include #include #include +#include "timers.h" #include "tools.h" using namespace vdrlive; @@ -42,7 +43,8 @@ using namespace vdrlive; <{ bool active = false; - for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) { + SortedTimers timers; + for (SortedTimers::iterator timer = timers.begin(); timer != timers.end(); ++timer) { timer->SetEventFromSchedule(); // make sure the event is current }> diff --git a/timers.cpp b/timers.cpp new file mode 100644 index 0000000..226a8a4 --- /dev/null +++ b/timers.cpp @@ -0,0 +1,18 @@ +#include "timers.h" + +static bool operator<( cTimer & left, cTimer & right ) +{ + return left.Compare( right ) < 0; +} + +namespace vdrlive { + +SortedTimers::SortedTimers() +{ + for ( cTimer* timer = Timers.First(); timer != 0; timer = Timers.Next( timer ) ) { + m_timers.push_back( *timer ); + } + m_timers.sort(); +} + +} // namespace vdrlive diff --git a/timers.h b/timers.h new file mode 100644 index 0000000..2ab1ee2 --- /dev/null +++ b/timers.h @@ -0,0 +1,26 @@ +#ifndef VDR_LIVE_TIMERS_H +#define VDR_LIVE_TIMERS_H + +#include +#include + +namespace vdrlive { + +class SortedTimers +{ +public: + typedef std::list< cTimer > List; + typedef List::iterator iterator; + + SortedTimers(); + + iterator begin() { return m_timers.begin(); } + iterator end() { return m_timers.end(); } + +private: + List m_timers; +}; + +} // namespace vdrlive + +#endif // VDR_LIVE_TIMERS_H -- cgit v1.2.3