1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HIVIEW_PLUGINS_EVENT_SERVICE_INCLUDE_SYS_EVENT_SERVICE_H 17 #define HIVIEW_PLUGINS_EVENT_SERVICE_INCLUDE_SYS_EVENT_SERVICE_H 18 #include <memory> 19 20 #include "event.h" 21 #include "event_json_parser.h" 22 #include "sys_event_service_adapter.h" 23 #include "plugin.h" 24 #include "sys_event_db_mgr.h" 25 #include "sys_event_stat.h" 26 27 namespace OHOS { 28 namespace HiviewDFX { 29 class SysEventService : public Plugin, public SysEventServiceBase { 30 public: 31 SysEventService(); 32 ~SysEventService(); 33 void OnLoad() override; 34 void OnUnload() override; 35 bool OnEvent(std::shared_ptr<Event>& event) override; 36 void Dump(int fd, const std::vector<std::string>& cmds) override; 37 38 private: 39 std::shared_ptr<SysEvent> Convert2SysEvent(std::shared_ptr<Event>& event); 40 private: 41 void SendEvent(std::shared_ptr<Event>& event); 42 std::unique_ptr<SysEventDbMgr> sysEventDbMgr_; 43 std::unique_ptr<SysEventStat> sysEventStat_; 44 std::unique_ptr<EventJsonParser> sysEventParser_; 45 std::atomic<bool> hasLoaded_; 46 }; // SysEventService 47 } // namespace HiviewDFX 48 } // namespace OHOS 49 #endif // HIVIEW_PLUGINS_EVENT_SERVICE_INCLUDE_SYS_EVENT_SERVICE_H 50