1 /*
2  * Copyright (c) 2021-2024 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 "plugin.h"
22 #include "sys_event_db_mgr.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 class SysEventStore : public Plugin {
27 public:
28     SysEventStore();
29     ~SysEventStore();
30     void OnLoad() override;
31     void OnUnload() override;
32     bool OnEvent(std::shared_ptr<Event>& event) override;
33 
34 private:
35     std::shared_ptr<SysEvent> Convert2SysEvent(std::shared_ptr<Event>& event);
36     bool IsNeedBackup(const std::string& dateStr);
37 
38 private:
39     std::unique_ptr<SysEventDbMgr> sysEventDbMgr_ = nullptr;
40     std::atomic<bool> hasLoaded_ { false };
41     std::string lastBackupTime_;
42 }; // SysEventService
43 } // namespace HiviewDFX
44 } // namespace OHOS
45 #endif // HIVIEW_PLUGINS_EVENT_SERVICE_INCLUDE_SYS_EVENT_SERVICE_H
46