1 /*
2 * Copyright (c) 2023 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 #include "model_manager_impl.h"
17
18 #include "config_operate.h"
19 #include "db_operate.h"
20 #include "database_manager.h"
21
22 namespace OHOS::Security::SecurityGuard {
GetDbOperate(std::string table)23 std::shared_ptr<IDbOperate> ModelManagerImpl::GetDbOperate(std::string table)
24 {
25 std::shared_ptr<IDbOperate> operate = nullptr;
26 if (table == "risk_event" || table == "audit_event") {
27 operate = std::make_shared<DbOperate>(table);
28 }
29 return operate;
30 }
31
GetConfigOperate()32 std::shared_ptr<IConfigOperate> ModelManagerImpl::GetConfigOperate()
33 {
34 return std::make_shared<ConfigOperate>();
35 }
36
SubscribeDb(std::vector<int64_t> eventIds,std::shared_ptr<IDbListener> listener)37 int32_t ModelManagerImpl::SubscribeDb(std::vector<int64_t> eventIds, std::shared_ptr<IDbListener> listener)
38 {
39 return DatabaseManager::GetInstance().SubscribeDb(eventIds, listener);
40 }
41
UnSubscribeDb(std::vector<int64_t> eventIds,std::shared_ptr<IDbListener> listener)42 int32_t ModelManagerImpl::UnSubscribeDb(std::vector<int64_t> eventIds, std::shared_ptr<IDbListener> listener)
43 {
44 return DatabaseManager::GetInstance().UnSubscribeDb(eventIds, listener);
45 }
46 } // namespace OHOS::Security::SecurityGuard