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 SetImageRealPath(const std::string& imageRealPath); 41 void Dump() const; 42 43 [[nodiscard]] int32_t GetScanProgress() const; 44 [[nodiscard]] int32_t GetScanPictureFd() const; 45 [[nodiscard]] bool GetIsFinal() const; 46 [[nodiscard]] int32_t GetPictureId() const; 47 [[nodiscard]] SteadyTimePoint GetScanTime() const; 48 [[nodiscard]] ScanErrorCode GetTaskCode() const; 49 [[nodiscard]] std::string GetImageRealPath() const; 50 51 virtual bool Marshalling(Parcel &parcel) const override; 52 static std::shared_ptr<ScanProgress> Unmarshalling(Parcel &parcel); 53 private: 54 void ReadFromParcel(Parcel &parcel); 55 56 private: 57 int32_t progress; // 0~100 58 int32_t fd; 59 bool isFinal; 60 int32_t pictureId; 61 SteadyTimePoint timePoint; 62 ScanErrorCode taskCode; 63 std::string imageRealPath; 64 }; 65 } // namespace OHOS::Scan 66 #endif // SCAN_PROGRESS_H 67