/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SECURITY_GUARD_CONFIG_DATA_MANAGER_H #define SECURITY_GUARD_CONFIG_DATA_MANAGER_H #include #include #include #include "config_define.h" namespace OHOS::Security::SecurityGuard { class ConfigDataManager { public: static ConfigDataManager &GetInstance(); void InsertModelMap(uint32_t modelId, const ModelCfg &config); void InsertEventMap(int64_t eventId, const EventCfg &config); void InsertModelToEventMap(uint32_t modelId, std::set eventIds); void InsertEventToTableMap(int64_t eventId, std::string table); void ResetModelMap(); void ResetEventMap(); void ResetModelToEventMap(); void ResetEventToTableMap(); std::vector GetEventIds(uint32_t modelId); std::vector GetAllEventIds(); std::vector GetAllModelIds(); bool GetModelConfig(uint32_t modelId, ModelCfg &config); bool GetEventConfig(int64_t eventId, EventCfg &config); std::string GetTableFromEventId(int64_t eventId); std::vector GetAppInfosByName(const std::string &appName); private: std::unordered_map> modelToEventMap_; std::unordered_map modelMap_; std::unordered_map eventMap_; std::unordered_map eventToTableMap_; std::mutex modelToEventMutex_; std::mutex modelMutex_; std::mutex eventMutex_; std::mutex eventToTableMutex_; }; } // OHOS::Security::SecurityGuard #endif // SECURITY_GUARD_CONFIG_DATA_MANAGER_H