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_SERVICE_INFO_UNIQUE_KEY_H 17 #define OHOS_DP_SERVICE_INFO_UNIQUE_KEY_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "distributed_device_profile_constants.h" 23 #include "dp_parcel.h" 24 25 namespace OHOS { 26 namespace DistributedDeviceProfile { 27 class ServiceInfoUniqueKey : public DpParcel { 28 public: ServiceInfoUniqueKey(const std::string & deviceId,const int32_t userId,const std::string & tokenId,const int64_t serviceId)29 ServiceInfoUniqueKey(const std::string& deviceId, const int32_t userId, const std::string& tokenId, 30 const int64_t serviceId) 31 : deviceId_(deviceId), 32 userId_(userId), 33 tokenId_(tokenId), 34 serviceId_(serviceId) 35 {} ServiceInfoUniqueKey(const std::string & deviceId,const int32_t userId,const std::string & bundleName)36 ServiceInfoUniqueKey(const std::string& deviceId, const int32_t userId, const std::string& bundleName) 37 : deviceId_(deviceId), 38 userId_(userId), 39 bundleName_(bundleName) 40 {} 41 ServiceInfoUniqueKey(); 42 ~ServiceInfoUniqueKey(); 43 44 std::string GetDeviceId() const; 45 void SetDeviceId(const std::string& deviceId); 46 int32_t GetUserId() const; 47 void SetUserId(const int32_t userId); 48 std::string GetTokenId() const; 49 void SetTokenId(const std::string& tokenId); 50 int64_t GetServiceId() const; 51 void SetServiceId(const int64_t serviceId); 52 std::string GetBundleName() const; 53 void SetBundleName(const std::string& bundleName); 54 bool operator<(const ServiceInfoUniqueKey& rhs) const; 55 56 bool Marshalling(MessageParcel& parcel) const override; 57 bool UnMarshalling(MessageParcel& parcel) override; 58 std::string dump() const override; 59 60 private: 61 std::string deviceId_ = ""; 62 int32_t userId_ = DEFAULT_USER_ID; 63 std::string tokenId_ = ""; 64 int64_t serviceId_ = DEFAULT_SERVICE_ID; 65 std::string bundleName_ = ""; 66 }; 67 } // namespace DistributedDeviceProfile 68 } // namespace OHOS 69 #endif //OHOS_DP_SERVICE_INFO_UNIQUE_KEY_H 70