• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FORM_RECORD_H
17 #define BUNDLE_ACTIVE_FORM_RECORD_H
18 
19 #include <cstdint>
20 #include <iosfwd>
21 #include <memory>
22 #include "parcel.h"
23 
24 namespace OHOS {
25 namespace DeviceUsageStats {
26 class BundleActiveFormRecord : public Parcelable {
27 public:
28     std::string formName_;
29     int32_t formDimension_;
30     int64_t formId_;
31     int64_t formLastUsedTime_;
32     int32_t count_;
33     int32_t userId_;
34 
35 public:
36     /*
37     * function: BundleActiveFormRecord, copy constructor.
38     * parameters: orig
39     */
40     BundleActiveFormRecord(const BundleActiveFormRecord& orig);
41     /*
42     * function: BundleActiveFormRecord, default constructor.
43     */
44     BundleActiveFormRecord();
45     /*
46     * function: BundleActiveFormRecord, use formName, formDimension, formId, timeStamp, userId to construct object.
47     * parameters: formName, formDimension, formId, timeStamp, userId
48     */
49     BundleActiveFormRecord(const std::string formName, const int32_t formDimension, const int64_t formId,
50         const int64_t timeStamp, const int32_t userId);
51     /*
52     * function: ~BundleActiveFormRecord, default destructor.
53     */
~BundleActiveFormRecord()54     ~BundleActiveFormRecord() {}
55     /*
56     * function: UpdateFormRecord, update form record by timestamp.
57     * parameters: timeStamp
58     */
59     void UpdateFormRecord(const int64_t timeStamp);
60     /*
61     * function: operator==, override operator ==.
62     * parameters: formRecord
63     * return: true if the formId_ is same.
64     */
65     bool operator==(const BundleActiveFormRecord& formRecord) const
66     {
67         return (this->formId_ == formRecord.formId_);
68     }
69     /*
70     * function: operator==, override operator ==.
71     * parameters: formId
72     * return: true if the formId_ is same.
73     */
74     bool operator==(const int64_t formId) const
75     {
76         return (this->formId_ == formId);
77     }
78     /*
79     * function: cmp, compare two BundleActiveFormRecord.
80     * parameters: formRecordA, formRecordB
81     * return: true if formRecordA.count_ > formRecordB.
82     */
83     static bool cmp(const BundleActiveFormRecord& formRecordA, const BundleActiveFormRecord& formRecordB);
84     /*
85     * function: Marshalling, mashalling form record object to parcel.
86     * parameters: parcel
87     * return: result of mashalling, true means successful, flase means failed.
88     */
89     bool Marshalling(Parcel &parcel) const override;
90     /*
91     * function: UnMarshalling, Unmashalling record object from parcel.
92     * parameters: parcel
93     * return: point to a BundleActiveFormRecord.
94     */
95     static std::shared_ptr<BundleActiveFormRecord> UnMarshalling(Parcel &parcel);
96     /*
97     * function: ToString, change form record object to string.
98     * return: string of form name, form id, form dimension, last used time and touch count.
99     */
100     std::string ToString();
101 };
102 }  // namespace DeviceUsageStats
103 }  // namespace OHOS
104 #endif  // BUNDLE_ACTIVE_FORM_RECORD_H
105 
106