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_SERVICES_INCLUDE_ORDERED_EVENT_RECORD_H
17 #define FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_ORDERED_EVENT_RECORD_H
18 
19 #include "common_event_record.h"
20 #include "common_event_subscriber_manager.h"
21 
22 namespace OHOS {
23 namespace EventFwk {
24 struct OrderedEventRecord : public CommonEventRecord {
25     enum EventState {
26         IDLE = 0,
27         RECEIVING,
28         RECEIVED,
29     };
30 
31     enum DeliveryState {
32         PENDING = 0,
33         DELIVERED,
34         SKIPPED,
35         TIMEOUT,
36     };
37 
38     std::vector<std::shared_ptr<EventSubscriberRecord>> receivers;
39     sptr<IRemoteObject> resultTo;
40     sptr<IRemoteObject> curReceiver;
41     std::vector<int> deliveryState;
42     int32_t enqueueClockTime;
43     int64_t dispatchTime;
44     int64_t receiverTime;
45     int64_t finishTime;
46     size_t nextReceiver;
47     int8_t state;
48     bool resultAbort;
49 
OrderedEventRecordOrderedEventRecord50     OrderedEventRecord()
51         : resultTo(nullptr),
52           curReceiver(nullptr),
53           enqueueClockTime(0),
54           dispatchTime(0),
55           receiverTime(0),
56           finishTime(0),
57           nextReceiver(0),
58           state(0),
59           resultAbort(false)
60     {}
61 
FillCommonEventRecordOrderedEventRecord62     inline void FillCommonEventRecord(const CommonEventRecord &commonEventRecord)
63     {
64         commonEventData = commonEventRecord.commonEventData;
65         publishInfo = commonEventRecord.publishInfo;
66         recordTime = commonEventRecord.recordTime;
67         userId = commonEventRecord.userId;
68         eventRecordInfo = commonEventRecord.eventRecordInfo;
69     }
70 };
71 }  // namespace EventFwk
72 }  // namespace OHOS
73 
74 #endif  // FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_ORDERED_EVENT_RECORD_H