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 #include "scan_range.h"
17 #include "scan_log.h"
18
19 namespace OHOS::Scan {
ScanRange()20 ScanRange::ScanRange() : minValue_(0), maxValue_(0), quantValue_(0)
21 {}
22
ScanRange(const ScanRange & right)23 ScanRange::ScanRange(const ScanRange &right)
24 {
25 minValue_ = right.minValue_;
26 maxValue_ = right.maxValue_;
27 quantValue_ = right.quantValue_;
28 }
29
operator =(const ScanRange & right)30 ScanRange &ScanRange::operator=(const ScanRange &right)
31 {
32 if (this != &right) {
33 minValue_ = right.minValue_;
34 maxValue_ = right.maxValue_;
35 quantValue_ = right.quantValue_;
36 }
37 return *this;
38 }
39
~ScanRange()40 ScanRange::~ScanRange()
41 {}
42
Reset()43 void ScanRange::Reset()
44 {
45 minValue_ = 0;
46 maxValue_ = 0;
47 quantValue_ = 0;
48 }
49
SetMinValue(const int32_t & minValue)50 void ScanRange::SetMinValue(const int32_t &minValue)
51 {
52 minValue_ = minValue;
53 }
54
SetMaxValue(const int32_t & maxValue)55 void ScanRange::SetMaxValue(const int32_t &maxValue)
56 {
57 maxValue_ = maxValue;
58 }
59
SetQuantValue(const int32_t & quantValue)60 void ScanRange::SetQuantValue(const int32_t &quantValue)
61 {
62 quantValue_ = quantValue;
63 }
64
GetMinValue() const65 int32_t ScanRange::GetMinValue() const
66 {
67 return minValue_;
68 }
69
GetMaxValue() const70 int32_t ScanRange::GetMaxValue() const
71 {
72 return maxValue_;
73 }
74
GetQuantValue() const75 int32_t ScanRange::GetQuantValue() const
76 {
77 return quantValue_;
78 }
79
ReadFromParcel(Parcel & parcel)80 void ScanRange::ReadFromParcel(Parcel &parcel)
81 {
82 SetMinValue(parcel.ReadInt32());
83
84 SetMaxValue(parcel.ReadInt32());
85
86 SetQuantValue(parcel.ReadInt32());
87 }
88
Marshalling(Parcel & parcel) const89 bool ScanRange::Marshalling(Parcel &parcel) const
90 {
91 parcel.WriteInt32(minValue_);
92
93 parcel.WriteInt32(maxValue_);
94
95 parcel.WriteInt32(quantValue_);
96 return true;
97 }
98
Unmarshalling(Parcel & parcel)99 std::shared_ptr<ScanRange> ScanRange::Unmarshalling(Parcel &parcel)
100 {
101 auto nativeObj = std::make_shared<ScanRange>();
102 nativeObj->ReadFromParcel(parcel);
103 return nativeObj;
104 }
105
Dump()106 void ScanRange::Dump()
107 {
108 SCAN_HILOGD("MinValue = %{public}d", minValue_);
109 SCAN_HILOGD("MaxValue = %{public}d", maxValue_);
110 SCAN_HILOGD("QuantValue = %{public}d", quantValue_);
111 }
112 } // namespace OHOS::Scan
113