1 /*
2  * Copyright (c) 2024 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 SCAN_PROGRESS_H
17 #define SCAN_PROGRESS_H
18 
19 #include <vector>
20 #include <chrono>
21 #include "parcel.h"
22 #include "scan_constant.h"
23 
24 
25 namespace OHOS::Scan {
26 using SteadyTimePoint = std::chrono::steady_clock::time_point;
27 class ScanProgress final : public Parcelable {
28 public:
29     explicit ScanProgress();
30     ScanProgress(const ScanProgress &right);
31     ScanProgress &operator=(const ScanProgress &right);
32     virtual ~ScanProgress();
33 
34     void SetScanProgress(const int32_t progress);
35     void SetScanPictureFd(const int32_t fd);
36     void SetIsFinal(const bool isFinal);
37     void SetPictureId(const int32_t pictureId);
38     void SetScanTime(SteadyTimePoint nowTime);
39     void SetTaskCode(ScanErrorCode taskCode);
40     void Dump() const;
41 
42     [[nodiscard]] int32_t GetScanProgress() const;
43     [[nodiscard]] int32_t GetScanPictureFd() const;
44     [[nodiscard]] bool GetIsFinal() const;
45     [[nodiscard]] int32_t GetPictureId() const;
46     [[nodiscard]] SteadyTimePoint GetScanTime() const;
47     [[nodiscard]] ScanErrorCode GetTaskCode() const;
48 
49     virtual bool Marshalling(Parcel &parcel) const override;
50     static std::shared_ptr<ScanProgress> Unmarshalling(Parcel &parcel);
51 private:
52     void ReadFromParcel(Parcel &parcel);
53 
54 private:
55     int32_t progress; // 0~100
56     int32_t fd;
57     bool isFinal;
58     int32_t pictureId;
59     SteadyTimePoint timePoint;
60     ScanErrorCode taskCode;
61 };
62 }  // namespace OHOS::Scan
63 #endif  // SCAN_PROGRESS_H
64