• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 "element_name.h"
17 
18 namespace OHOS {
19 namespace AppExecFwk {
SetElementDeviceID(ElementName * element,const char * deviceId)20 void ElementName::SetElementDeviceID(ElementName *element, const char *deviceId)
21 {
22     if (!element) {
23         return;
24     }
25     element->SetDeviceID(deviceId);
26 }
27 
SetElementBundleName(ElementName * element,const char * bundleName)28 void ElementName::SetElementBundleName(ElementName *element, const char *bundleName)
29 {
30     if (!element) {
31         return;
32     }
33     element->SetBundleName(bundleName);
34 }
35 
SetElementAbilityName(ElementName * element,const char * abilityName)36 void ElementName::SetElementAbilityName(ElementName *element, const char *abilityName)
37 {
38     if (!element) {
39         return;
40     }
41     element->SetAbilityName(abilityName);
42 }
43 
ClearElement(ElementName * element)44 void ElementName::ClearElement(ElementName *element)
45 {
46     if (!element) {
47         return;
48     }
49     element->SetDeviceID("");
50     element->SetBundleName("");
51     element->SetAbilityName("");
52 }
53 
ElementName(const std::string & deviceId,const std::string & bundleName,const std::string & abilityName)54 ElementName::ElementName(const std::string &deviceId, const std::string &bundleName, const std::string &abilityName)
55     : deviceId_(deviceId), bundleName_(bundleName), abilityName_(abilityName)
56 {
57 }
58 
ElementName()59 ElementName::ElementName()
60 {
61 }
62 
~ElementName()63 ElementName::~ElementName()
64 {
65 }
66 
GetURI() const67 std::string ElementName::GetURI() const
68 {
69     return deviceId_ + "/" + bundleName_ + "/" + abilityName_;
70 }
71 
operator ==(const ElementName & element) const72 bool ElementName::operator==(const ElementName &element) const
73 {
74     return (deviceId_ == element.GetDeviceID() && bundleName_ == element.GetBundleName() &&
75             abilityName_ == element.GetAbilityName());
76 }
77 
ReadFromParcel(Parcel & parcel)78 bool ElementName::ReadFromParcel(Parcel &parcel)
79 {
80     return true;
81 }
82 
Unmarshalling(Parcel & parcel)83 ElementName *ElementName::Unmarshalling(Parcel &parcel)
84 {
85     ElementName *elementName = new (std::nothrow) ElementName();
86     if (elementName && !elementName->ReadFromParcel(parcel)) {
87         delete elementName;
88         elementName = nullptr;
89     }
90     return elementName;
91 }
92 
Marshalling(Parcel & parcel) const93 bool ElementName::Marshalling(Parcel &parcel) const
94 {
95     return true;
96 }
97 } // namespace AppExecFwk
98 } // namespace OHOS
99