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_LOCAL_SERVICE_INFO_MANAGER_H 17 #define OHOS_DP_LOCAL_SERVICE_INFO_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 "local_service_info.h" 29 #include "local_service_info_rdb_adapter.h" 30 #include "single_instance.h" 31 32 namespace OHOS { 33 namespace DistributedDeviceProfile { 34 using namespace OHOS::NativeRdb; 35 class LocalServiceInfoManager { 36 DECLARE_SINGLE_INSTANCE(LocalServiceInfoManager); 37 public: 38 int32_t Init(); 39 int32_t UnInit(); 40 int32_t PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo); 41 int32_t UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo); 42 int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, 43 int32_t pinExchangeType, LocalServiceInfo& localServiceInfo); 44 int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType); 45 private: 46 int32_t ConvertToLocalServiceInfo(std::shared_ptr<ResultSet> resultSet, LocalServiceInfo& localServiceInfo); 47 int32_t LocalServiceInfoToEntries(const LocalServiceInfo& localServiceInfo, ValuesBucket& values); 48 int32_t CreateTable(); 49 int32_t CreateIndex(); 50 51 private: 52 }; 53 } // DistributedDeviceProfile 54 } // OHOS 55 #endif // OHOS_DP_SERVICE_INFO_PROFILE_MANAGER_H 56