common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / systemservice / logger_service / server / include / ss_logger_error_event_cfg.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_SS_LoggerService
19 /// \brief    This file supports error event logging configuration.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
23 #define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_
24 #include <system_service/ss_system_manager_if.h>
25 #include <vector>
26 #include <map>
27 #include <string>
28
29 #include "ss_logger_cfg.h"
30
31 typedef UI_32 ARTIFACT_BIT_MASK;
32 typedef UI_32 EVENT_BIT_MASK;
33
34 #define  NBR_ARTIFACT_BITS  (sizeof(ARTIFACT_BIT_MASK) * 8)
35
36 enum EVENT_BIT {
37   EVENT_BIT_NONE = 0x00000000,
38   EVENT_BIT_POPUP = 1 << (UI_32) 1,
39   EVENT_BIT_CAN_NOTIFICATION = 1 << (UI_32) 2,
40   EVENT_BIT_DIAG = 1 << (UI_32) 3,
41 };
42
43 struct TLoggingErrorEventInformation {
44   ARTIFACT_BIT_MASK ArtifactBitMask;
45   EVENT_BIT_MASK EventBitMask;
46 };
47 struct TLoggingArtifactCfg {
48   EErrorEventType ErrorType;
49   TLoggingErrorEventInformation Information;
50 };
51 struct TLoggerErrorEvent {
52   TLoggerErrorEvent()
53       : EventType(eErrorEventTypeMaxValue),
54         ModuleName(""),
55         isNeedReboot(FALSE),
56         EventBitMask(EVENT_BIT_NONE) {  // LCOV_EXCL_BR_LINE 11:Unexpected branch
57   }
58   TLoggerErrorEvent(SMErrorEventNtfData l_SMErrorEvent) {  // NOLINT (runtime/explicit)
59     EventType = l_SMErrorEvent.EventType;
60     ModuleName = l_SMErrorEvent.ModuleName;
61     isNeedReboot = l_SMErrorEvent.isNeedReboot;
62     EventBitMask = EVENT_BIT_NONE;
63   }
64   EErrorEventType EventType;
65   std::string ModuleName;
66   BOOL isNeedReboot;
67   EVENT_BIT_MASK EventBitMask;
68 };
69 struct TLoggingArtifact;
70
71 typedef EFrameworkunifiedStatus (*TLoggingCbFunction)(HANDLE, TLoggingArtifact);
72
73 enum ECallbackType {
74   eCbTypePath = 0,
75   eCbTypeFunction,
76   eCbTypeInvalid
77 };
78
79 struct TLoggingArtifactCallback {
80   ECallbackType Type;
81   std::string Path;
82   TLoggingCbFunction Function;
83 };
84
85 struct TLoggingArtifactInformation {
86   std::string OwnerServiceName;
87   UI_32 RequestTimeoutMs;
88   TLoggingArtifactCallback Cb;
89   BOOL Remove;
90 };
91 struct TLoggingArtifact {
92   EArtifactId ArtifactId;
93   TLoggingArtifactInformation Information;
94 };
95
96 struct TLoggingArtifactResponse {
97   EArtifactId ArtifactId;
98   std::string Filepath;
99   BOOL Remove;
100 };
101
102 //////////////////////////////////////////////////////////////////////////////////////////
103 /////  External function definition for Logger callbacks
104 //////////////////////////////////////////////////////////////////////////////////////////
105 extern EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact);
106 extern EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp,
107                                       TLoggingArtifact f_artifact);
108
109 typedef std::map<EErrorEventType, TLoggingErrorEventInformation> TArtifactBitMaskMap;
110 typedef std::map<EArtifactId, TLoggingArtifactInformation> TArtifactMap;
111 typedef std::vector<TLoggingArtifactResponse> TArtifactResponseVec;
112
113 class CErrorEventCfg {
114  public:
115   CErrorEventCfg(void);
116
117   ~CErrorEventCfg(void);
118
119   EFrameworkunifiedStatus Initialize(CLoggerCfg* p_logger_cfg);
120
121   void GetArtifactRequestVec(
122       EErrorEventType f_eventType,
123       std::vector<TLoggingArtifact> &f_refArtifactRequestVec);  // NOLINT (runtime/references)
124   EVENT_BIT_MASK GetEventsForErrorEvent(EErrorEventType f_eventType);
125  private:
126   UI_32 ValidateConfiguration();
127   TArtifactBitMaskMap m_errorEventTypeToArtifactBitMaskMap;
128   TArtifactMap m_errorArtifactMap;
129   UI_32 m_ext_log_num;
130
131   static TLoggingArtifactCfg m_loggerErrorEventCfgTbl[eErrorEventTypeMaxValue];
132   static TLoggingArtifact m_loggerErrorArtifactCfgTbl[eArtifactIdMaxValue];
133 };
134
135 #endif  // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_CFG_H_