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_EVENT_CESFWK_KITS_NATIVE_INCLUDE_PUBLISH_INFO_H 17 #define FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_PUBLISH_INFO_H 18 19 #include "parcel.h" 20 21 namespace OHOS { 22 namespace EventFwk { 23 class CommonEventPublishInfo : public Parcelable { 24 public: 25 CommonEventPublishInfo(); 26 27 /** 28 * A constructor used to create a CommonEventPublishInfo instance by copying 29 * parameters from an existing one. 30 * 31 * @param commonEventPublishInfo Indicates the publish info. 32 */ 33 explicit CommonEventPublishInfo(const CommonEventPublishInfo &commonEventPublishInfo); 34 35 ~CommonEventPublishInfo(); 36 37 /** 38 * Sets whether the type of a common event is sticky or not. 39 * 40 * @param sticky Indicates the type of a common event is sticky or not 41 */ 42 void SetSticky(bool sticky); 43 44 /** 45 * Obtains whether it is a sticky common event, which can be set 46 * by SetSticky(bool). 47 * 48 * @return Returns the common event is sticky or not. 49 */ 50 bool IsSticky() const; 51 52 /** 53 * Sets permissions for subscribers. 54 * 55 * @param subscriberPermissions Indicates the permissions for subscribers. 56 */ 57 void SetSubscriberPermissions(const std::vector<std::string> &subscriberPermissions); 58 59 /** 60 * Obtains subscriber permissions to a common event, which can be set by 61 * setSubscriberPermissions(const std::vector<std::string>&). 62 * 63 * @return Returns the permissions for subscribers. 64 */ 65 const std::vector<std::string> &GetSubscriberPermissions() const; 66 67 /** 68 * Sets whether the type of a common event is ordered or not. 69 * 70 * @param ordered Indicates the type of a common event is ordered or not. 71 */ 72 void SetOrdered(bool ordered); 73 74 /** 75 * 76 * Obtains whether it is an ordered common event, which can be set by setOrdered(boolean). 77 * set by SetOrdered(bool). 78 * 79 * @return Returns the type of a common event is ordered or not. 80 */ 81 bool IsOrdered() const; 82 83 /** 84 * Sets the bundleName. 85 * 86 * @param bundleName Indicates the bundleName of a common event. 87 */ 88 void SetBundleName(const std::string &bundleName); 89 90 /** 91 * Obtains the bundleName of a common event 92 * 93 * @return Returns the bundleName of a common event. 94 */ 95 std::string GetBundleName() const; 96 97 /** 98 * Marshals a CommonEventData object into a Parcel. 99 * 100 * @param parcel Indicates specified Parcel object. 101 * @return Returns true if success; false otherwise. 102 */ 103 virtual bool Marshalling(Parcel &parcel) const override; 104 105 /** 106 * UnMarshals a Parcel object into a CommonEventData. 107 * 108 * @return Returns the common event data. 109 */ 110 static CommonEventPublishInfo *Unmarshalling(Parcel &parcel); 111 112 private: 113 /** 114 * Reads a CommonEventData object from a Parcel. 115 * 116 * @param parcel Indicates specified Parcel object. 117 */ 118 bool ReadFromParcel(Parcel &parcel); 119 120 private: 121 bool sticky_; 122 bool ordered_; 123 std::string bundleName_; 124 std::vector<std::string> subscriberPermissions_; 125 }; 126 } // namespace EventFwk 127 } // namespace OHOS 128 129 #endif // FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_PUBLISH_INFO_H