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_DP_SERVICE_INFO_PROFILE_MANAGER_H 17 #define OHOS_DP_SERVICE_INFO_PROFILE_MANAGER_H 18 19 #include <cstdint> 20 #include <memory> 21 #include <mutex> 22 #include <string> 23 #include <vector> 24 25 #include "kvstore_observer.h" 26 #include "values_bucket.h" 27 28 #include "service_info_profile.h" 29 #include "service_info_rdb_adapter.h" 30 #include "service_info_unique_key.h" 31 #include "single_instance.h" 32 33 namespace OHOS { 34 namespace DistributedDeviceProfile { 35 using namespace OHOS::NativeRdb; 36 class ServiceInfoProfileManager { 37 DECLARE_SINGLE_INSTANCE(ServiceInfoProfileManager); 38 public: 39 int32_t Init(); 40 int32_t UnInit(); 41 int32_t PutServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile); 42 int32_t DeleteServiceInfoProfile(const ServiceInfoUniqueKey& key); 43 int32_t UpdateServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile); 44 int32_t GetServiceInfoProfileByUniqueKey(const ServiceInfoUniqueKey& key, ServiceInfoProfile& serviceInfoProfile); 45 int32_t GetServiceInfoProfileListByTokenId(const ServiceInfoUniqueKey& key, 46 std::vector<ServiceInfoProfile>& serviceInfoProfiles); 47 int32_t GetAllServiceInfoProfileList(std::vector<ServiceInfoProfile>& serviceInfoProfiles); 48 int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, 49 std::vector<ServiceInfoProfile>& serviceInfoProfiles); 50 private: 51 int32_t ConvertToServiceInfo(std::shared_ptr<ResultSet> resultSet, ServiceInfoProfile& serviceInfo); 52 int32_t ServiceInfoProfileToEntries(const ServiceInfoProfile& serviceInfo, ValuesBucket& values); 53 int32_t CreateTable(); 54 int32_t CreateIndex(); 55 56 private: 57 }; 58 } // DistributedDeviceProfile 59 } // OHOS 60 #endif // OHOS_DP_SERVICE_INFO_PROFILE_MANAGER_H 61