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 BUNDLE_ACTIVE_EVENT_STATS_H
17 #define BUNDLE_ACTIVE_EVENT_STATS_H
18 
19 #include <cstdint>
20 #include <iosfwd>
21 #include <memory>
22 #include "parcel.h"
23 
24 namespace OHOS {
25 namespace DeviceUsageStats {
26 class BundleActiveEventStats : public Parcelable {
27 public:
28     int32_t eventId_;
29     int64_t beginTimeStamp_;
30     int64_t endTimeStamp_;
31     int64_t lastEventTime_;
32     int64_t totalTime_;
33     int32_t count_;
34     int32_t uid_;
35     std::string name_;
36 
37     /*
38     * function: BundleActiveEventStats, default constructor.
39     */
40     BundleActiveEventStats();
41     /*
42     * function: BundleActiveEventStats, copy constructor.
43     * parameters: orig
44     */
45     BundleActiveEventStats(const BundleActiveEventStats& orig);
46     /*
47     * function: GetEventId, get eventId.
48     * return: member eventId_.
49     */
50     int32_t GetEventId();
51     /*
52     * function: GetFirstTimeStamp, get first time stamp.
53     * return: member beginTimeStamp_.
54     */
55     int64_t GetFirstTimeStamp();
56     /*
57     * function: GetLastTimeStamp, get last time stamp.
58     * return: member endTimeStamp_.
59     */
60     int64_t GetLastTimeStamp();
61     /*
62     * function: GetLastEventTime, get last event time.
63     * return: member lastEventTime_.
64     */
65     int64_t GetLastEventTime();
66     /*
67     * function: GetTotalTime, get total time.
68     * return: member totalTime_.
69     */
70     int64_t GetTotalTime();
71     /*
72     * function: GetCount, get count.
73     * return: member count_.
74     */
75     int32_t GetCount();
76     /*
77     * function: add, add statistics from another BundleActvieEventStats object.
78     * parameters: right
79     */
80     void add(const BundleActiveEventStats& right);
81 
82     /*
83     * function: Marshalling, mashalling event stats object to parcel.
84     * parameters: parcel
85     * return: result of mashalling, true means successful, flase means failed.
86     */
87     bool Marshalling(Parcel &parcel) const override;
88 
89     /*
90     * function: UnMarshalling, Unmashalling event stats object from parcel.
91     * parameters: parcel
92     * return: point to a BundleActiveEventStats.
93     */
94     static std::shared_ptr<BundleActiveEventStats> UnMarshalling(Parcel &parcel);
95 };
96 }  // namespace DeviceUsageStats
97 }  // namespace OHOS
98 #endif  // BUNDLE_ACTIVE_EVENT_STATS_H
99 
100