Remove unused directories and files in video_in_hal
[staging/basesystem.git] / service / system / system_manager / server / include / heartbeat / ss_hb_thread.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_SystemManager
19 /// \brief    This file provides support for the application heartbeat system.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #ifndef HEARTBEAT_WORKER_H_  // NOLINT
24 #define HEARTBEAT_WORKER_H_
25
26 #include <native_service/frameworkunified_types.h>
27 #include <native_service/frameworkunified_framework_if.h>
28 #include <native_service/frameworkunified_multithreading.h>
29 #include <system_service/ss_system_timer.h>
30
31 #include "ss_hb_session.h"
32 #include "ss_sm_config.h"
33
34
35 class CHeartBeatThread {
36  public:
37   explicit CHeartBeatThread(HANDLE f_hThread);
38   virtual ~CHeartBeatThread();
39
40   ///////////////////////////
41   /// HBPublishAvailabilityStatus
42   /// At HeartBeat sends NTFY_Availability with availability
43   /// notification to alert client that HeartBeat is available/not available.
44   ///
45   /// \param [in] hThread
46   ///         HANDLE - Handle of HeartBeat
47   ///
48   /// \return status
49   ///         EFrameworkunifiedStatus - success or error
50   ///
51   ////////////////////////////////////////////////////////////////////////////////////////////
52   EFrameworkunifiedStatus HBPublishAvailabilityStatus(HANDLE hThread, BOOL f_AvailabiltyStatus);
53
54   ///////////////////////////
55   /// HBOnStartThread
56   /// Creates and starts the HeartBeat timer
57   ///
58   /// \param [in] hThread
59   ///         HANDLE - Handle of HeartBeat
60   ///
61   /// \return status
62   ///         EFrameworkunifiedStatus - success or error
63   ///
64   ////////////////////////////////////////////////////////////////////////////////////////////
65   EFrameworkunifiedStatus HBOnStartThread(HANDLE hThread);
66
67
68   ///////////////////////////
69   /// HBOnStopThread
70   /// Stops and deletes the HeartBeat timer
71   ///
72   /// \param [in] hThread
73   ///         HANDLE - Handle of HeartBeat
74   ///
75   /// \return status
76   ///         EFrameworkunifiedStatus - success or error
77   ///
78   ////////////////////////////////////////////////////////////////////////////////////////////
79   EFrameworkunifiedStatus HBOnStopThread(HANDLE hThread);
80
81   ////////////////////////////////////////////////////////////////////////////////////////////
82   /// HBOnPrintConnections
83   /// Prints all active sessions connected to HeartBeat
84   ///
85   /// \param [in] hThread
86   ///         HANDLE - Handle of HeartBeat
87   ///
88   /// \return status
89   ///         EFrameworkunifiedStatus - success or error
90   ///
91   ////////////////////////////////////////////////////////////////////////////////////////////
92   EFrameworkunifiedStatus HBOnPrintConnections(HANDLE hThread);
93
94   ////////////////////////////////////////////////////////////////////////////////////////////
95   /// HBOnPrintStack
96   /// Prints all sessions connected to HeartBeat
97   ///
98   /// \param [in] hThread
99   ///         HANDLE - Handle of HeartBeat
100   ///
101   /// \return status
102   ///         EFrameworkunifiedStatus - success or error
103   ///
104   ////////////////////////////////////////////////////////////////////////////////////////////
105   EFrameworkunifiedStatus HBOnPrintStack(HANDLE hThread);
106
107   ///////////////////////////
108   /// HBOnTimerExpiry
109   /// When APP timer expires, this method sends the HeartBeat request to the client.
110   ///
111   /// \param [in] hThread
112   ///         HANDLE - Handle of HeartBeat
113   ///
114   /// \return status
115   ///         EFrameworkunifiedStatus - success or error
116   ///
117   ////////////////////////////////////////////////////////////////////////////////////////////
118   EFrameworkunifiedStatus HBOnTimerExpiry(HANDLE hThread);
119
120   ///////////////////////////
121   /// HBOnClientResponse
122   /// When the response from a client is received, this method updates the map
123   /// containing client status to indicate the response.
124   ///
125   ///
126   /// \param [in] hThread
127   ///         HANDLE - Handle of HeartBeat
128   ///
129   /// \return status
130   ///         EFrameworkunifiedStatus - success or error
131   ///
132   ////////////////////////////////////////////////////////////////////////////////////////////
133   EFrameworkunifiedStatus HBOnClientResponse(HANDLE hThread);
134
135   ///////////////////////////
136   /// HBOnPeriodicStatusRequest
137   /// Reply to Status request from System Manager
138   ///
139   /// \param [in] hThread
140   ///         HANDLE - Handle of HeartBeat
141   ///
142   /// \return status
143   ///         EFrameworkunifiedStatus - success or error
144   ///
145   ////////////////////////////////////////////////////////////////////////////////////////////
146   EFrameworkunifiedStatus HBOnPeriodicStatusRequest(HANDLE hThread);
147
148
149   ///////////////////////////
150   /// HBOnAvailCheckRequest
151   /// Reply to service's availability condition request from System Manager
152   ///
153   /// \param [in] hThread
154   ///         HANDLE - Handle of HeartBeat
155   ///
156   /// \return status
157   ///         EFrameworkunifiedStatus - success or error
158   ///
159   ////////////////////////////////////////////////////////////////////////////////////////////
160   EFrameworkunifiedStatus HBOnAvailCheckRequest(HANDLE hThread);
161
162   ///////////////////////////
163   /// HBOnRemoveModule
164   /// Upon receiving delete module notification from sysmgr, this method removes
165   /// a client from the client session map.
166   ///
167   /// \param [in] hThread
168   ///         HANDLE - Handle of HeartBeat
169   ///
170   /// \return status
171   ///         EFrameworkunifiedStatus - success or error
172   ///
173   ////////////////////////////////////////////////////////////////////////////////////////////
174   EFrameworkunifiedStatus HBOnRemoveModule(HANDLE hApp);
175
176   ///////////////////////////
177   /// HBOnAppendModule
178   /// Upon receiving append module notification from sysmgr, this method append
179   /// a client from the client session map.
180   ///
181   /// \param [in] hThread
182   ///         HANDLE - Handle of HeartBeat
183   ///
184   /// \return status
185   ///         EFrameworkunifiedStatus - success or error
186   ///
187   ////////////////////////////////////////////////////////////////////////////////////////////
188   EFrameworkunifiedStatus HBOnAppendModule(HANDLE hApp);
189
190   // Service notification handlers
191   EFrameworkunifiedStatus HBSendRequest(HANDLE hApp);
192   EFrameworkunifiedStatus HBCheckHeartBeatResponses(HANDLE hThread);
193   EFrameworkunifiedStatus HBDeleteRegisteredClientEntry(PSTR pModuleName);
194
195   EFrameworkunifiedStatus HeartBeatTimerInit(HANDLE hThread);
196   EFrameworkunifiedStatus HeartBeatTimersDelete(void);
197
198  private:
199   CHeartBeatSessionHandler m_oSessionHandler;
200   TimerCtrl                m_oTimerCtrl;
201   UI_32                    m_HBTimerID;
202   HBConfigParameters       m_HBConfigParams;
203   SI_32                    m_NextChkIndex;
204   HANDLE                   m_hThread;
205 };
206 #endif  // HEARTBEAT_WORKER_H_  // NOLINT