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