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_ASYNC_COMMON_EVENT_RESULT_H 17 #define FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_ASYNC_COMMON_EVENT_RESULT_H 18 19 #include "iremote_object.h" 20 21 namespace OHOS { 22 namespace EventFwk { 23 class AsyncCommonEventResult { 24 public: 25 /** 26 * Creates a AsyncCommonEventResult instance based on the parameters. 27 * 28 * @param resultCode Indicates the result code of the current ordered common event. 29 * @param resultData Indicates the result data of the current ordered common event. 30 * @param ordered Indicates the type of the current ordered common event is ordered or not. 31 * @param sticky Indicates the type of the current sticky common event is sticky or not. 32 * @param token Indicates the remote object of the current ordered common event. 33 */ 34 AsyncCommonEventResult(const int32_t &resultCode, const std::string &resultData, const bool &ordered, 35 const bool &sticky, const sptr<IRemoteObject> &token); 36 37 ~AsyncCommonEventResult(); 38 39 /** 40 * Sets the result code of the current ordered common event. 41 * 42 * @param code Indicates the result code of the current ordered common event 43 * @return Returns true if successful; false otherwise. 44 */ 45 bool SetCode(const int32_t &code); 46 47 /** 48 * Obtains the result code of the current ordered common event. 49 * 50 * @return Returns the result code of the current ordered common event 51 */ 52 int32_t GetCode() const; 53 54 /** 55 * Sets the result data of the current ordered common event. 56 * 57 * @param data Indicates the result data of the current ordered common event. 58 * @return Returns true if successful; false otherwise. 59 */ 60 bool SetData(const std::string &data); 61 62 /** 63 * Obtains the result data of the current ordered common event. 64 * 65 * @return Returns the result data of the current ordered common event 66 */ 67 std::string GetData() const; 68 69 /** 70 * Sets the result of the current ordered common event. 71 * 72 * @param code Indicates the result code of the current ordered common event. 73 * @param data Indicates the result data of the current ordered common event. 74 * @return Returns true if successful; false otherwise. 75 */ 76 bool SetCodeAndData(const int32_t &code, const std::string &data); 77 78 /** 79 * Cancels the current ordered common event. 80 * 81 * @return Returns true if successful; false otherwise. 82 */ 83 bool AbortCommonEvent(); 84 85 /** 86 * Clears the abort state of the current ordered common event. 87 * 88 * @return Returns true if successful; false otherwise. 89 */ 90 bool ClearAbortCommonEvent(); 91 92 /** 93 * Checks whether the current ordered common event should be aborted. 94 * 95 * @return Returns true common event should be aborted; false otherwise. 96 */ 97 bool GetAbortCommonEvent() const; 98 99 /** 100 * Finishes processing the current ordered common event. 101 * 102 * @return Returns true if finishes processing the current ordered common event; false otherwise. 103 */ 104 bool FinishCommonEvent(); 105 106 /** 107 * Checks whether the current common event is an ordered common event. 108 * 109 * @return Returns true if the current common event is an ordered common event; false otherwise. 110 */ 111 bool IsOrderedCommonEvent() const; 112 113 /** 114 * Checks whether the current common event is a sticky common event. 115 * 116 * @return Returns true if the current common event is a sticky common event; false otherwise. 117 */ 118 bool IsStickyCommonEvent() const; 119 120 /** 121 * Checks whether the current common event is ordered. 122 * 123 * @return Returns true if the current common event is ordered; false otherwise. 124 */ 125 bool CheckSynchronous() const; 126 127 private: 128 int32_t resultCode_; 129 std::string resultData_; 130 bool ordered_; 131 bool sticky_; 132 sptr<IRemoteObject> token_; 133 bool abortEvent_; 134 bool finished_; 135 }; 136 } // namespace EventFwk 137 } // namespace OHOS 138 139 #endif // FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_ASYNC_COMMON_EVENT_RESULT_H