• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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      * Create a AsyncCommonEventResult instance based on the parameters.
27      *
28      * @param resultCode the result code of the current ordered common event
29      * @param resultData the result data of the current ordered common event
30      * @param ordered the type of the current ordered common event is ordered or not
31      * @param sticky the type of the current sticky common event is sticky or not
32      * @param token the remote object of the current ordered common event
33      */
34     AsyncCommonEventResult(const int &resultCode, const std::string &resultData, const bool &ordered,
35         const bool &sticky, const sptr<IRemoteObject> &token);
36 
37     /**
38      * Default deconstructor used to deconstruct.
39      *
40      */
41     ~AsyncCommonEventResult();
42 
43     /**
44      * Set the result code of the current ordered common event.
45      *
46      * @param code the result code of the current ordered common event
47      */
48     bool SetCode(const int &code);
49 
50     /**
51      * Obtain the result code of the current ordered common event.
52      *
53      * @return the result code of the current ordered common event
54      */
55     int GetCode() const;
56 
57     /**
58      * Set the result data of the current ordered common event.
59      *
60      * @param data the result data of the current ordered common event.
61      */
62     bool SetData(const std::string &data);
63 
64     /**
65      * Obtain the result data of the current ordered common event.
66      *
67      * @return the result data of the current ordered common event
68      */
69     std::string GetData() const;
70 
71     /**
72      * Set the result of the current ordered common event.
73      *
74      * @param code the result code of the current ordered common event.
75      * @param data the result data of the current ordered common event.
76      */
77     bool SetCodeAndData(const int &code, const std::string &data);
78 
79     /**
80      * Cancel the current ordered common event.
81      */
82     bool AbortCommonEvent();
83 
84     /**
85      * Clear the abort state of the current ordered common event.
86      */
87     bool ClearAbortCommonEvent();
88 
89     /**
90      * Check whether the current ordered common event should be aborted.
91      */
92     bool GetAbortCommonEvent() const;
93 
94     /**
95      * Finishe processing the current ordered common event.
96      */
97     bool FinishCommonEvent();
98 
99     /**
100      * Check whether the current common event is an ordered common event.
101      */
102     bool IsOrderedCommonEvent() const;
103 
104     /**
105      * Check whether the current common event is a sticky common event.
106      */
107     bool IsStickyCommonEvent() const;
108 
109     /**
110      * Check whether the current common event is ordered.
111      */
112     bool CheckSynchronous() const;
113 
114 private:
115     int resultCode_;
116     std::string resultData_;
117     bool ordered_;
118     bool sticky_;
119     sptr<IRemoteObject> token_;
120     bool abortEvent_;
121     bool finished_;
122 };
123 }  // namespace EventFwk
124 }  // namespace OHOS
125 
126 #endif  // FOUNDATION_EVENT_CESFWK_KITS_NATIVE_INCLUDE_ASYNC_COMMON_EVENT_RESULT_H