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 #include "service_info_unique_key.h"
17
18 #include "cJSON.h"
19
20 #include "distributed_device_profile_constants.h"
21 #include "macro_utils.h"
22 #include "profile_utils.h"
23
24 namespace OHOS {
25 namespace DistributedDeviceProfile {
26 namespace {
27 const std::string TAG = "ServiceInfoUniqueKey";
28 }
ServiceInfoUniqueKey()29 ServiceInfoUniqueKey::ServiceInfoUniqueKey()
30 {
31 }
~ServiceInfoUniqueKey()32 ServiceInfoUniqueKey::~ServiceInfoUniqueKey()
33 {
34 }
GetDeviceId() const35 std::string ServiceInfoUniqueKey::GetDeviceId() const
36 {
37 return deviceId_;
38 }
39
SetDeviceId(const std::string & deviceId)40 void ServiceInfoUniqueKey::SetDeviceId(const std::string& deviceId)
41 {
42 deviceId_ = deviceId;
43 }
44
GetUserId() const45 int32_t ServiceInfoUniqueKey::GetUserId() const
46 {
47 return userId_;
48 }
49
SetUserId(const int32_t userId)50 void ServiceInfoUniqueKey::SetUserId(const int32_t userId)
51 {
52 userId_ = userId;
53 }
54
GetTokenId() const55 std::string ServiceInfoUniqueKey::GetTokenId() const
56 {
57 return tokenId_;
58 }
59
SetTokenId(const std::string & tokenId)60 void ServiceInfoUniqueKey::SetTokenId(const std::string& tokenId)
61 {
62 tokenId_ = tokenId;
63 }
64
GetServiceId() const65 int64_t ServiceInfoUniqueKey::GetServiceId() const
66 {
67 return serviceId_;
68 }
69
SetServiceId(const int64_t serviceId)70 void ServiceInfoUniqueKey::SetServiceId(const int64_t serviceId)
71 {
72 serviceId_ = serviceId;
73 }
74
GetBundleName() const75 std::string ServiceInfoUniqueKey::GetBundleName() const
76 {
77 return bundleName_;
78 }
79
SetBundleName(const std::string & bundleName)80 void ServiceInfoUniqueKey::SetBundleName(const std::string& bundleName)
81 {
82 bundleName_ = bundleName;
83 }
84
operator <(const ServiceInfoUniqueKey & rhs) const85 bool ServiceInfoUniqueKey::operator<(const ServiceInfoUniqueKey& rhs) const
86 {
87 return serviceId_ < rhs.serviceId_;
88 }
89
Marshalling(MessageParcel & parcel) const90 bool ServiceInfoUniqueKey::Marshalling(MessageParcel& parcel) const
91 {
92 WRITE_HELPER_RET(parcel, String, deviceId_, false);
93 WRITE_HELPER_RET(parcel, Int32, userId_, false);
94 WRITE_HELPER_RET(parcel, String, tokenId_, false);
95 WRITE_HELPER_RET(parcel, Int64, serviceId_, false);
96 WRITE_HELPER_RET(parcel, String, bundleName_, false);
97 return true;
98 }
99
UnMarshalling(MessageParcel & parcel)100 bool ServiceInfoUniqueKey::UnMarshalling(MessageParcel& parcel)
101 {
102 READ_HELPER_RET(parcel, String, deviceId_, false);
103 READ_HELPER_RET(parcel, Int32, userId_, false);
104 READ_HELPER_RET(parcel, String, tokenId_, false);
105 READ_HELPER_RET(parcel, Int64, serviceId_, false);
106 READ_HELPER_RET(parcel, String, bundleName_, false);
107 return true;
108 }
109
dump() const110 std::string ServiceInfoUniqueKey::dump() const
111 {
112 return "";
113 }
114 } // namespace DistributedDeviceProfile
115 } // namespace OHOS
116