Init basesystem source codes.
[staging/basesystem.git] / systemservice / system_manager / server / include / heartbeat / ss_hb_session.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 SS_HEARTBEAT_SESSION_H_  // NOLINT
24 #define SS_HEARTBEAT_SESSION_H_
25
26 #include <native_service/frameworkunified_types.h>
27 #include <system_service/ss_heartbeat_service_protocol.h>
28 #include <system_service/ss_system_manager_if.h>
29 #include <system_service/ss_system_manager_if_local.h>
30 #include <map>
31 #include <string>
32
33 #include "ss_hb_if.h"
34
35 // The name of the module that is trying to open a session with Heart Beat
36 typedef std::string SubscriberName;
37
38 /*
39  *
40  */
41 class CHeartBeatSessionHandler {
42  public:
43   CHeartBeatSessionHandler();
44   virtual ~CHeartBeatSessionHandler();
45
46   EFrameworkunifiedStatus HBProcessClientResponse(HANDLE hApp);
47
48   EFrameworkunifiedStatus HBEntrySubscriber(SubscriberName &f_Subscriber);  // NOLINT
49   EFrameworkunifiedStatus HBSendRequest(HANDLE hApp, SI_32 f_HeartBeatIntervalRepeat, SI_32 f_ChkIndex);
50   EFrameworkunifiedStatus HBCheckResponses(THbReportData &f_tReportData, UI_32 f_MaxHeartBeatRetryCount,  // NOLINT
51         SI_32 f_HeartBeatIntervalRepeat, SI_32 f_ChkIndex);
52
53   EFrameworkunifiedStatus HBDeleteRegisteredClientEntry(HANDLE f_hThread, PSTR pQueueName);
54   EFrameworkunifiedStatus HBAvailableCheck(THbAvailCheck &check);  // NOLINT
55
56   VOID HBPrintConnection();
57   VOID HBPrintStack(UI_32 f_MaxHeartBeatRetryCount);
58
59  private:
60   class HbSessionInfo {
61    public:
62     std::string szName;
63     HANDLE hSession;
64     BOOL   fRunning;
65     BOOL   fHeartBeatRequestSent;
66     BOOL   fHeartBeatResponseReceived;
67     UI_8   HeartBeatRetryCount;
68     BOOL   fHeartBeatTimedOut;
69     BOOL   fisAvailability;
70
71     // Copy constructor
72     HbSessionInfo(const HbSessionInfo &f_SessionInfo) {
73       szName                     = f_SessionInfo.szName;
74       hSession                   = f_SessionInfo.hSession;
75       fRunning                   = f_SessionInfo.fRunning;
76       fHeartBeatRequestSent      = f_SessionInfo.fHeartBeatRequestSent;
77       fHeartBeatResponseReceived = f_SessionInfo.fHeartBeatResponseReceived;
78       HeartBeatRetryCount        = f_SessionInfo.HeartBeatRetryCount;
79       fHeartBeatTimedOut         = f_SessionInfo.fHeartBeatTimedOut;
80       fisAvailability            = f_SessionInfo.fisAvailability;
81     }
82
83     explicit HbSessionInfo(SubscriberName f_Subscriber);
84   };
85
86   typedef std::map<SubscriberName, HbSessionInfo> HbSessionMap;
87   typedef HbSessionMap::iterator HbSessionIter;
88
89   HbSessionMap m_mapHbSessions;
90 };
91 #endif  // SS_HEARTBEAT_SESSION_H_  // NOLINT