| 1 |
/* |
| 2 |
* Copyright (C) 2022 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
#include "SkinTimer.h" |
| 9 |
|
| 10 |
#include "interfaces/info/Info.h" |
| 11 |
|
| 12 |
CSkinTimer::CSkinTimer(const std::string& name, |
| 13 |
const INFO::InfoPtr& startCondition, |
| 14 |
const INFO::InfoPtr& resetCondition, |
| 15 |
const INFO::InfoPtr& stopCondition, |
| 16 |
const CGUIAction& startActions, |
| 17 |
const CGUIAction& stopActions, |
| 18 |
bool resetOnStart) |
| 19 |
: m_name{name}, |
| 20 |
m_startCondition{startCondition}, |
| 21 |
m_resetCondition{resetCondition}, |
| 22 |
m_stopCondition{stopCondition}, |
| 23 |
m_startActions{startActions}, |
| 24 |
m_stopActions{stopActions}, |
| 25 |
m_resetOnStart{resetOnStart} |
| 26 |
{ |
| 27 |
} |
| 28 |
|
| 29 |
void CSkinTimer::Start() |
| 30 |
{ |
| 31 |
if (m_resetOnStart) |
| 32 |
{ |
| 33 |
CStopWatch::StartZero(); |
| 34 |
} |
| 35 |
else |
| 36 |
{ |
| 37 |
CStopWatch::Start(); |
| 38 |
} |
| 39 |
OnStart(); |
| 40 |
} |
| 41 |
|
| 42 |
void CSkinTimer::Reset() |
| 43 |
{ |
| 44 |
CStopWatch::Reset(); |
| 45 |
} |
| 46 |
|
| 47 |
void CSkinTimer::Stop() |
| 48 |
{ |
| 49 |
CStopWatch::Stop(); |
| 50 |
OnStop(); |
| 51 |
} |
| 52 |
|
| 53 |
bool CSkinTimer::VerifyStartCondition() const |
| 54 |
{ |
| 55 |
return m_startCondition && m_startCondition->Get(INFO::DEFAULT_CONTEXT); |
| 56 |
} |
| 57 |
|
| 58 |
bool CSkinTimer::VerifyResetCondition() const |
| 59 |
{ |
| 60 |
return m_resetCondition && m_resetCondition->Get(INFO::DEFAULT_CONTEXT); |
| 61 |
} |
| 62 |
|
| 63 |
bool CSkinTimer::VerifyStopCondition() const |
| 64 |
{ |
| 65 |
return m_stopCondition && m_stopCondition->Get(INFO::DEFAULT_CONTEXT); |
| 66 |
} |
| 67 |
|
| 68 |
const std::string& CSkinTimer::GetName() const |
| 69 |
{ |
| 70 |
return m_name; |
| 71 |
} |
| 72 |
|
| 73 |
INFO::InfoPtr CSkinTimer::GetStartCondition() const |
| 74 |
{ |
| 75 |
return m_startCondition; |
| 76 |
} |
| 77 |
|
| 78 |
INFO::InfoPtr CSkinTimer::GetResetCondition() const |
| 79 |
{ |
| 80 |
return m_resetCondition; |
| 81 |
} |
| 82 |
|
| 83 |
INFO::InfoPtr CSkinTimer::GetStopCondition() const |
| 84 |
{ |
| 85 |
return m_stopCondition; |
| 86 |
} |
| 87 |
|
| 88 |
const CGUIAction& CSkinTimer::GetStartActions() const |
| 89 |
{ |
| 90 |
return m_startActions; |
| 91 |
} |
| 92 |
|
| 93 |
const CGUIAction& CSkinTimer::GetStopActions() const |
| 94 |
{ |
| 95 |
return m_stopActions; |
| 96 |
} |
| 97 |
|
| 98 |
bool CSkinTimer::ResetsOnStart() const |
| 99 |
{ |
| 100 |
return m_resetOnStart; |
| 101 |
} |
| 102 |
|
| 103 |
void CSkinTimer::OnStart() |
| 104 |
{ |
| 105 |
if (m_startActions.HasAnyActions()) |
| 106 |
{ |
| 107 |
m_startActions.ExecuteActions(); |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
void CSkinTimer::OnStop() |
| 112 |
{ |
| 113 |
if (m_stopActions.HasAnyActions()) |
| 114 |
{ |
| 115 |
m_stopActions.ExecuteActions(); |
| 116 |
} |
| 117 |
} |