Remove unused directories and files in video_in_hal
[staging/basesystem.git] / service / system / power_service / server / include / ss_power_state_hysteresis.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_PowerService
19 /// \brief    This file supports power service hysteresis management.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #ifndef POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
23 #define POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_
24
25 #include "ss_power_config.h"
26
27 class PowerStateHysteresis {
28  public:
29   PowerStateHysteresis()
30       : m_unTries(0) {
31     bzero(&m_tHysteresisInfo, sizeof(m_tHysteresisInfo));
32   }
33
34   virtual ~PowerStateHysteresis() {  // LCOV_EXCL_START 14: do it when power off
35     AGL_ASSERT_NOT_TESTED();  // LCOV_EXCL_LINE 200: test assert
36     m_unTries = 0;
37   }
38   // LCOV_EXCL_STOP 14: do it when power off
39   explicit PowerStateHysteresis(PowerConfigParams::PowerOffInfo & info)  // NOLINT (runtime/references)
40       : m_unTries(0),
41         m_tHysteresisInfo(info) {
42   }
43   void set(PowerConfigParams::PowerOffInfo & info) {  // NOLINT (runtime/references)
44     m_tHysteresisInfo = info;
45   }
46   BOOL getEnabled() const {
47     return m_tHysteresisInfo.hysteresis.enabled;
48   }
49   UI_32 getTimeout() const {
50     return m_tHysteresisInfo.hysteresis.timeout;
51   }
52   UI_32 getTries() const {
53     return m_tHysteresisInfo.hysteresis.tries;
54   }
55
56   void clearTryCounter() {
57     m_unTries = 0;
58   }
59   void bumbTryCounter() {
60     m_unTries++;
61   }
62   BOOL maxTries() const {
63     if (m_unTries < getTries())
64       return FALSE;
65     else
66       return TRUE;
67   }
68
69  private:
70   UI_32 m_unTries;
71   PowerConfigParams::PowerOffInfo m_tHysteresisInfo;
72 };
73
74 #endif  // POWER_SERVICE_SERVER_INCLUDE_SS_POWER_STATE_HYSTERESIS_H_