1 /* 2 * Copyright (c) 2021 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ELEMENT_NAME_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ELEMENT_NAME_H 18 19 #include <string> 20 21 #include "parcel.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 26 class ElementName : public Parcelable { 27 /* 28 * How to locate unique Ability: deviceId/bundleName/abilityName 29 */ 30 public: 31 ElementName(const std::string &deviceId, const std::string &bundleName, const std::string &abilityName); 32 ElementName(); 33 ~ElementName(); 34 35 std::string GetURI() const; 36 bool operator==(const ElementName &element) const; 37 SetDeviceID(const std::string & id)38 inline void SetDeviceID(const std::string &id) 39 { 40 deviceId_ = id; 41 } 42 GetDeviceID()43 inline std::string GetDeviceID() const 44 { 45 return deviceId_; 46 } 47 SetBundleName(const std::string & name)48 inline void SetBundleName(const std::string &name) 49 { 50 bundleName_ = name; 51 } 52 GetBundleName()53 inline std::string GetBundleName() const 54 { 55 return bundleName_; 56 } 57 SetAbilityName(const std::string & name)58 inline void SetAbilityName(const std::string &name) 59 { 60 abilityName_ = name; 61 } 62 GetAbilityName()63 inline std::string GetAbilityName() const 64 { 65 return abilityName_; 66 } 67 68 bool ReadFromParcel(Parcel &parcel); 69 virtual bool Marshalling(Parcel &parcel) const override; 70 static ElementName *Unmarshalling(Parcel &parcel); 71 72 void SetElementDeviceID(ElementName *element, const char *deviceId); 73 void SetElementBundleName(ElementName *element, const char *bundleName); 74 void SetElementAbilityName(ElementName *element, const char *abilityName); 75 void ClearElement(ElementName *element); 76 77 private: 78 std::string deviceId_; 79 std::string bundleName_; 80 std::string abilityName_; 81 }; 82 83 } // namespace AppExecFwk 84 } // namespace OHOS 85 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ELEMENT_NAME_H 86