• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_I_DISTRIBUTED_DEVICE_PROFILE_H
17 #define OHOS_DP_I_DISTRIBUTED_DEVICE_PROFILE_H
18 
19 #include <cstdint>
20 #include <map>
21 
22 #include "iremote_broker.h"
23 
24 namespace OHOS {
25 namespace DistributedDeviceProfile {
26 class CharacteristicProfile {
27 public:
28     CharacteristicProfile() = default;
29 
CharacteristicProfile(const std::string & deviceId,const std::string & serviceName,const std::string & characteristicKey,const std::string & characteristicValue)30     CharacteristicProfile(const std::string &deviceId, const std::string &serviceName,
31         const std::string &characteristicKey, const std::string &characteristicValue)
32         : deviceId_(deviceId), serviceName_(serviceName), characteristicKey_(characteristicKey),
33         characteristicValue_(characteristicValue)
34     {
35     }
36 
37 private:
38     std::string deviceId_;
39     std::string serviceName_;
40     std::string characteristicKey_;
41     std::string characteristicValue_;
42 };
43 
44 class SubscribeInfo {
45 public:
46     SubscribeInfo() = default;
47 
SubscribeInfo(int32_t saId,const std::string & subscribeKey)48     SubscribeInfo(int32_t saId, const std::string &subscribeKey) : saId_(saId), subscribeKey_(subscribeKey)
49     {
50     }
51 
GetSaId()52     int32_t GetSaId() const
53     {
54         return saId_;
55     }
56 
GetSubscribeKey()57     std::string GetSubscribeKey() const
58     {
59         return subscribeKey_;
60     }
61 
62 private:
63     int32_t saId_ = -1;
64     std::string subscribeKey_;
65 };
66 
67 class IDistributedDeviceProfile : public IRemoteBroker {
68 public:
69     IDistributedDeviceProfile() = default;
70     virtual ~IDistributedDeviceProfile() = default;
71 
72     virtual int32_t PutCharacteristicProfile(const CharacteristicProfile &characteristicProfile) = 0;
73     virtual int32_t GetCharacteristicProfile(const std::string &deviceId, const std::string &serviceName,
74         const std::string &characteristicId, CharacteristicProfile &characteristicProfile) = 0;
75     virtual int32_t SubscribeDeviceProfile(const SubscribeInfo &subscribeInfo) = 0;
76     virtual int32_t UnSubscribeDeviceProfile(const SubscribeInfo &subscribeInfo) = 0;
77     virtual int32_t SendSubscribeInfos(std::map<std::string, SubscribeInfo> listenerMap) = 0;
78 
79     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DeviceProfile.IDistributedDeviceProfile");
80 };
81 } // namespace DistributedDeviceProfile
82 } // namespace OHOS
83 #endif // OHOS_DP_I_DISTRIBUTED_DEVICE_PROFILE_H
84