1 /* 2 * Copyright (c) 2024 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_STATIC_PROFILE_MANAGER_H 17 #define OHOS_DP_STATIC_PROFILE_MANAGER_H 18 19 #include "characteristic_profile.h" 20 #include "dm_device_info.h" 21 #include "kv_adapter.h" 22 #include "single_instance.h" 23 24 namespace OHOS { 25 namespace DistributedDeviceProfile { 26 class StaticProfileManager { 27 DECLARE_SINGLE_INSTANCE(StaticProfileManager); 28 29 public: 30 int32_t Init(); 31 int32_t UnInit(); 32 int32_t ReInit(); 33 int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile); 34 int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, 35 const std::string& characteristicKey, CharacteristicProfile& charProfile); 36 int32_t GetAllCharacteristicProfile(std::vector<CharacteristicProfile>& staticCapabilityProfiles); 37 void E2ESyncStaticProfile(const DistributedHardware::DmDeviceInfo deviceInfo); 38 39 private: 40 int32_t GenerateStaticInfoProfile(const CharacteristicProfile& staticCapabilityProfile, 41 std::unordered_map<std::string, CharacteristicProfile>& staticInfoProfiles); 42 43 private: 44 std::mutex staticStoreMutex_; 45 std::shared_ptr<IKVAdapter> staticProfileStore_ = nullptr; 46 }; 47 } // namespace DistributedDeviceProfile 48 } // namespace OHOS 49 #endif // OHOS_DP_STATIC_PROFILE_MANAGER_H 50