• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_BASE_EVENT_STORE_INCLUDE_SYS_EVENT_DAO_H
17 #define HIVIEW_BASE_EVENT_STORE_INCLUDE_SYS_EVENT_DAO_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "sys_event.h"
24 #include "sys_event_query.h"
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 namespace EventStore {
29 enum class StoreType {
30     FAULT = 1,
31     STATISTIC = 2,
32     SECURITY = 3,
33     BEHAVIOR = 4,
34 };
35 
36 class SysEventDao {
37 public:
38     static std::shared_ptr<SysEventQuery> BuildQuery(StoreType type);
39     static std::shared_ptr<SysEventQuery> BuildQuery(uint16_t eventType);
40     static std::shared_ptr<SysEventQuery> BuildQuery(const std::string& dbFile);
41     static int Insert(std::shared_ptr<SysEvent> sysEvent);
42     static int Delete(std::shared_ptr<SysEventQuery> sysEventQuery, int limit = 100);
43     static int Update(std::shared_ptr<SysEvent> sysEvent, bool isNotifyChange = true);
44     static int BackupDB(StoreType type);
45     static int CloseDB(StoreType type);
46     static int DeleteDB(StoreType type);
47     static int GetNum(StoreType type);
48     static std::string GetDataDir();
49     static std::string GetDataFile(StoreType type);
50     static void GetDataFiles(std::vector<std::string>& dbFiles);
51     static std::string GetBakFile(StoreType type);
52 }; // SysEventDao
53 } // EventStore
54 } // namespace HiviewDFX
55 } // namespace OHOS
56 #endif // HIVIEW_BASE_EVENT_STORE_INCLUDE_SYS_EVENT_DAO_H