1 /* 2 * Copyright (c) 2023 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_CHARACTERISTIC_PROFILE_H 17 #define OHOS_DP_CHARACTERISTIC_PROFILE_H 18 19 #include <cstdint> 20 #include <string> 21 #include "distributed_device_profile_constants.h" 22 #include "dp_parcel.h" 23 24 namespace OHOS { 25 namespace DistributedDeviceProfile { 26 class CharacteristicProfile : public DpParcel { 27 public: CharacteristicProfile(const std::string & deviceId,const std::string & serviceName,const std::string & characteristicKey,const std::string & characteristicValue)28 CharacteristicProfile(const std::string& deviceId, const std::string& serviceName, 29 const std::string& characteristicKey, const std::string& characteristicValue) 30 : deviceId_(deviceId), 31 serviceName_(serviceName), 32 characteristicKey_(characteristicKey), 33 characteristicValue_(characteristicValue) 34 {} CharacteristicProfile(const std::string & deviceId,const std::string & serviceName,const std::string & characteristicKey,const std::string & characteristicValue,const bool isMultiUser,const int32_t userId)35 CharacteristicProfile(const std::string& deviceId, const std::string& serviceName, 36 const std::string& characteristicKey, const std::string& characteristicValue, const bool isMultiUser, 37 const int32_t userId) 38 : deviceId_(deviceId), 39 serviceName_(serviceName), 40 characteristicKey_(characteristicKey), 41 characteristicValue_(characteristicValue), 42 isMultiUser_(isMultiUser), 43 userId_(userId) 44 {} 45 CharacteristicProfile() = default; 46 ~CharacteristicProfile() = default; 47 48 std::string GetDeviceId() const; 49 void SetDeviceId(const std::string& deviceId); 50 std::string GetServiceName() const; 51 void SetServiceName(const std::string& serviceName); 52 std::string GetCharacteristicKey() const; 53 void SetCharacteristicKey(const std::string& characteristicId); 54 std::string GetCharacteristicValue() const; 55 void SetCharacteristicValue(const std::string& characteristicValue); 56 bool IsMultiUser() const; 57 void SetIsMultiUser(bool isMultiUser); 58 int32_t GetUserId() const; 59 void SetUserId(int32_t userId); 60 bool Marshalling(MessageParcel& parcel) const override; 61 bool UnMarshalling(MessageParcel& parcel) override; 62 bool operator!=(const CharacteristicProfile& charProfile) const; 63 std::string dump() const override; 64 65 private: 66 std::string deviceId_ = ""; 67 std::string serviceName_ = ""; 68 std::string characteristicKey_ = ""; 69 std::string characteristicValue_ = ""; 70 bool isMultiUser_ = false; 71 int32_t userId_ = DEFAULT_USER_ID; 72 }; 73 } // namespace DistributedDeviceProfile 74 } // namespace OHOS 75 #endif // OHOS_DP_CHARACTERISTIC_PROFILE_H 76