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_PROFILE_CONTROLLER_H
17 #define OHOS_DP_PROFILE_CONTROLLER_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "characteristic_profile.h"
24 #include "device_profile.h"
25 #include "ikv_adapter.h"
26 #include "service_profile.h"
27 
28 namespace OHOS {
29 namespace DistributedDeviceProfile {
30 class ProfileControlUtils {
31 public:
32     static int32_t PutDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, const DeviceProfile& deviceProfile);
33     static int32_t PutServiceProfile(std::shared_ptr<IKVAdapter> kvStore, const ServiceProfile& serviceProfile);
34     static int32_t PutServiceProfileBatch(std::shared_ptr<IKVAdapter> kvStore,
35         const std::vector<ServiceProfile>& serviceProfiles);
36     static int32_t PutCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore,
37         const CharacteristicProfile& charProfile);
38     static int32_t PutSwitchCharacteristicProfile(const std::string& appId,
39         const CharacteristicProfile& charProfile); //写入开关数据
40     static int32_t PutCharacteristicProfileBatch(std::shared_ptr<IKVAdapter> kvStore,
41         const std::vector<CharacteristicProfile>& charProfiles);
42     static int32_t PutSwitchCharacteristicProfileBatch(const std::string& appId,
43         const std::vector<CharacteristicProfile>& charProfiles); //批量写入开关数据
44     static int32_t GetDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
45         DeviceProfile& deviceProfile);
46     static int32_t GetServiceProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
47         const std::string& serviceName, ServiceProfile& serviceProfile);
48     static int32_t GetCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
49         const std::string& serviceName, const std::string& characteristicKey, CharacteristicProfile& charProfile);
50     static int32_t GetSwitchCharacteristicProfile(const std::string& appId, const std::string& deviceId,
51     const std::string& serviceName, const std::string& characteristicKey, CharacteristicProfile& charProfile);
52     static int32_t DeleteServiceProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
53         const std::string& serviceName);
54     static int32_t DeleteCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
55         const std::string& serviceName, const std::string& characteristicKey);
56     static int32_t GetAllDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, std::vector<DeviceProfile>& deviceProfiles);
57     static int32_t GetAllServiceProfile(std::shared_ptr<IKVAdapter> kvStore,
58         std::vector<ServiceProfile>& serviceProfiles);
59     static int32_t GetAllCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore,
60         std::vector<CharacteristicProfile>& charProfiles);
61     static int32_t RefreshLocalSwitchProfile(const std::string& appId);
62 };
63 } // namespace DeviceProfile
64 } // namespace OHOS
65 #endif // OHOS_DP_DEVICE_PROFILE_MANAGER_H