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