common_library: gettid is multiple declaration in cl_error
[staging/basesystem.git] / video_in_hal / systemservice / logger_service / server / include / ss_logger_error_event_storage.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.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
23 #define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_
24
25 #include <sys/types.h>
26 #include <pthread.h>
27 #include <mqueue.h>
28 #include <time.h>
29 #include <native_service/frameworkunified_types.h>
30 #include <ss_logger_error_event_cfg.h>
31 #include <stub/Clock_API.h>
32 #include <string>
33 #include "ss_logger_cfg.h"
34
35 enum ELoggerStorageThreadCommands {
36   eLoggerStorageThreadCmdOK = 0xAFFE,
37   eLoggerStorageThreadCmdWriteFailed,
38   eLoggerStorageThreadCmdNotFound,
39   eLoggerStorageThreadCmdNoWritten
40 };
41
42 class CLoggerErrorEventStorage {
43  public:
44   CLoggerErrorEventStorage();
45   virtual ~CLoggerErrorEventStorage();
46
47   EFrameworkunifiedStatus Initialize(HANDLE f_hApp, std::string f_ParentName,
48                         CLoggerCfg *f_pLoggerCfg);
49
50   EFrameworkunifiedStatus Start(std::string f_target, TArtifactResponseVec f_responseVector,
51                    uint32_t f_time);
52
53   void ThreadFunction(void);
54   void Cleanup(void);
55
56  private:
57   static void* ThreadFunctionWrapper(void* param);
58   static void CleanupWrapper(void* param);
59
60   EFrameworkunifiedStatus PackageAndPlaceArtifacts(std::string f_archiveDestination,
61                                       TArtifactResponseVec &f_responseVector,  // NOLINT (runtime/references)
62                                       uint32_t l_logTime);
63
64   SI_32 CopyFiles(std::string f_archiveDestination,
65                   TArtifactResponseVec &f_responseVector, BOOL isDeleteFiles);  // NOLINT (runtime/references)
66
67   EFrameworkunifiedStatus RemoveDeprecatedArtifacts(TArtifactResponseVec &f_responseVector);  // NOLINT (runtime/references)
68   HANDLE m_parentMcQueue;
69   pthread_t m_thread;
70   pthread_mutex_t m_mutex;
71   mqd_t m_sendQueue;
72   mqd_t m_receiveQueue;
73   std::string m_destination;
74   TArtifactResponseVec m_responseVec;
75   struct mq_attr m_mqattr;
76   SI_32 m_mutexInit;
77   CLoggerCfg *m_pLoggerCfg;
78   SLoggerStorageInfo m_loggerStorageInfo;
79   uint32_t m_logTime;
80 };
81
82 #endif  // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_ERROR_EVENT_STORAGE_H_