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_SWITCH_PROFILE_MANAGER_H
17 #define OHOS_DP_SWITCH_PROFILE_MANAGER_H
18 
19 #include <mutex>
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 
24 #include "characteristic_profile.h"
25 #include "single_instance.h"
26 
27 namespace OHOS {
28 namespace DistributedDeviceProfile {
29 class SwitchProfileManager {
30 DECLARE_SINGLE_INSTANCE(SwitchProfileManager);
31 
32 public:
33     int32_t Init();
34     int32_t UnInit();
35     int32_t ReInit();
36     int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile);
37     int32_t PutCharacteristicProfileBatch(const std::vector<CharacteristicProfile>& charProfiles);
38     int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName,
39         const std::string& characteristicKey, CharacteristicProfile& charProfile);
40     int32_t RefreshLocalSwitchProfile();
41     int32_t GetLocalSwitchFromDB(uint32_t& localSwitch, uint32_t& switchLength);
42 private:
43     int32_t GenerateSwitchInfoProfile(const CharacteristicProfile& switchProfile,
44         std::unordered_map<std::string, CharacteristicProfile> switchProfileMap);
45     std::mutex switchProfileMutex_;
46 };
47 } // namespace DistributedDeviceProfile
48 } // namespace OHOS
49 #endif // OHOS_DP_SWITCH_PROFILE_MANAGER_H
50