4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
23 #include "StdString.h"
24 #include "Stopwatch.h"
25 #include "threads/CriticalSection.h"
26 #include "threads/Thread.h"
30 struct SAlarmClockEvent
34 CStdString m_strCommand;
38 class CAlarmClock : public CThread
43 void Start(const CStdString& strName, float n_secs, const CStdString& strCommand, bool bSilent = false, bool bLoop = false);
44 inline bool IsRunning() const
49 inline bool HasAlarm(const CStdString& strName)
51 // note: strName should be lower case only here
52 // No point checking it at the moment due to it only being called
53 // from GUIInfoManager (which is always lowercase)
54 // CLog::Log(LOGDEBUG,"checking for %s",strName.c_str());
55 return (m_event.find(strName) != m_event.end());
58 double GetRemaining(const CStdString& strName)
60 std::map<CStdString,SAlarmClockEvent>::iterator iter;
61 if ((iter=m_event.find(strName)) != m_event.end())
63 return iter->second.m_fSecs-iter->second.watch.GetElapsedSeconds();
69 void Stop(const CStdString& strName, bool bSilent = false);
70 virtual void Process();
72 std::map<CStdString,SAlarmClockEvent> m_event;
73 CCriticalSection m_events;
78 extern CAlarmClock g_alarmClock;