• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace OHOS::Scan {
25 using SteadyTimePoint = std::chrono::steady_clock::time_point;
26 class ScanProgress final : public Parcelable {
27 public:
28     explicit ScanProgress();
29     ScanProgress(const ScanProgress &right);
30     ScanProgress &operator=(const ScanProgress &right);
31     virtual ~ScanProgress();
32 
33     void SetScanProgress(const int32_t progress);
34     void SetScanPictureFd(const int32_t fd);
35     void SetIsFinal(const bool isFinal);
36     void SetPictureId(const int32_t pictureId);
37     void SetScanTime(SteadyTimePoint nowTime);
38     void SetTaskCode(ScanErrorCode taskCode);
39     void SetImageRealPath(const std::string &imageRealPath);
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     [[nodiscard]] std::string GetImageRealPath() const;
49 
50     virtual bool Marshalling(Parcel &parcel) const override;
51     static std::shared_ptr<ScanProgress> Unmarshalling(Parcel &parcel);
52 private:
53     void ReadFromParcel(Parcel &parcel);
54 
55 private:
56     int32_t progress_; // 0~100
57     int32_t fd_;
58     bool isFinal_;
59     int32_t pictureId_;
60     SteadyTimePoint timePoint_;
61     ScanErrorCode taskCode_;
62     std::string imageRealPath_;
63 };
64 }  // namespace OHOS::Scan
65 #endif  // SCAN_PROGRESS_H
66