• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 OHOS_INSIGHT_INTENT_DB_CACHE_H
17 #define OHOS_INSIGHT_INTENT_DB_CACHE_H
18 
19 #include <mutex>
20 #include <set>
21 #include <singleton.h>
22 #include <vector>
23 #include "insight_intent_rdb_storage_mgr.h"
24 
25 namespace OHOS {
26 namespace AbilityRuntime {
27 class InsightIntentDbCache : public std::enable_shared_from_this<InsightIntentDbCache> {
28     DECLARE_DELAYED_SINGLETON(InsightIntentDbCache)
29 public:
30     void InitInsightIntentCache(const int32_t userId);
31     void GetAllInsightIntentGenericInfo(std::vector<ExtractInsightIntentGenericInfo> &genericInfos);
32     void GetInsightIntentGenericInfoByName(const std::string &bundleName,
33         std::vector<ExtractInsightIntentGenericInfo> &genericInfos);
34     void GetInsightIntentGenericInfo(const std::string &bundleName, const std::string &moduleName,
35         const std::string &intentName, ExtractInsightIntentGenericInfo &genericInfos);
36     void GetAllInsightIntentInfo(const int32_t userId, std::vector<ExtractInsightIntentInfo> &infos);
37     void GetInsightIntentInfoByName(const std::string &bundleName, const int32_t userId,
38         std::vector<ExtractInsightIntentInfo> &infos);
39     void GetInsightIntentInfo(const std::string &bundleName, const std::string &moduleName,
40         const std::string &intentName, const int32_t userId, ExtractInsightIntentInfo &infos);
41     int32_t SaveInsightIntentTotalInfo(const std::string &bundleName, const std::string &moduleName,
42         const int32_t userId, ExtractInsightIntentProfileInfoVec profileInfos);
43     int32_t DeleteInsightIntentTotalInfo(const std::string &bundleName,
44         const std::string &moduleName, const int32_t userId);
45     int32_t DeleteInsightIntentByUserId(const int32_t userId);
46 private:
47     int32_t userId_ = -1;
48     mutable std::mutex genericInfosMutex_;
49     std::map<std::string, std::vector<ExtractInsightIntentGenericInfo>> intentGenericInfos_;
50 };
51 }  // namespace AbilityRuntime
52 }  // namespace OHOS
53 #endif  // OHOS_INSIGHT_INTENT_DB_CACHE_H
54