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 LOCATION_LOCATING_REQUIRED_DATA_CONFIG_H
17#define LOCATION_LOCATING_REQUIRED_DATA_CONFIG_H
18
19#include <parcel.h>
20#include <string>
21
22namespace OHOS {
23namespace Location {
24class LocatingRequiredDataConfig : public Parcelable {
25public:
26    LocatingRequiredDataConfig()
27    {
28        type_ = 0;
29        needStartScan_ = false;
30        scanIntervalMs_ = 0;
31        scanTimeoutMs_ = DEFAULT_TIMEOUT_30S;
32        fixNumber_ = 0;
33    }
34
35    explicit LocatingRequiredDataConfig(LocatingRequiredDataConfig& LocatingRequiredDataConfig)
36    {
37        SetType(LocatingRequiredDataConfig.GetType());
38        SetNeedStartScan(LocatingRequiredDataConfig.GetNeedStartScan());
39        SetScanIntervalMs(LocatingRequiredDataConfig.GetScanIntervalMs());
40        SetScanTimeoutMs(LocatingRequiredDataConfig.GetScanTimeoutMs());
41    }
42
43    ~LocatingRequiredDataConfig() override = default;
44
45    inline int GetType() const
46    {
47        return type_;
48    }
49
50    inline void SetType(int type)
51    {
52        type_ = type;
53    }
54
55    inline bool GetNeedStartScan() const
56    {
57        return needStartScan_;
58    }
59
60    inline void SetNeedStartScan(bool needStartScan)
61    {
62        needStartScan_ = needStartScan;
63    }
64
65    inline int GetScanIntervalMs() const
66    {
67        return scanIntervalMs_;
68    }
69
70    inline void SetScanIntervalMs(int scanIntervalMs)
71    {
72        scanIntervalMs_ = scanIntervalMs;
73    }
74
75    inline int GetScanTimeoutMs() const
76    {
77        return scanTimeoutMs_;
78    }
79
80    inline void SetScanTimeoutMs(int scanTimeoutMs)
81    {
82        scanTimeoutMs_ = scanTimeoutMs;
83    }
84
85    inline int GetFixNumber() const
86    {
87        return fixNumber_;
88    }
89
90    inline void SetFixNumber(int fixNumber)
91    {
92        fixNumber_ = fixNumber;
93    }
94
95    void ReadFromParcel(Parcel& parcel)
96    {
97        type_ =  parcel.ReadInt32();
98        needStartScan_ =  parcel.ReadBool();
99        scanIntervalMs_ = parcel.ReadInt32();
100        scanTimeoutMs_ = parcel.ReadInt32();
101        fixNumber_ = parcel.ReadInt32();
102    }
103
104    bool Marshalling(Parcel& parcel) const override
105    {
106        return parcel.WriteInt32(type_) &&
107            parcel.WriteBool(needStartScan_) &&
108            parcel.WriteInt32(scanIntervalMs_) &&
109            parcel.WriteInt32(scanTimeoutMs_) &&
110            parcel.WriteInt32(fixNumber_);
111    }
112
113    static std::shared_ptr<LocatingRequiredDataConfig> Unmarshalling(Parcel& parcel)
114    {
115        auto locatingRequiredDataConfig = std::make_shared<LocatingRequiredDataConfig>();
116        locatingRequiredDataConfig->ReadFromParcel(parcel);
117        return locatingRequiredDataConfig;
118    }
119
120    std::string ToString()
121    {
122        std::string str = "type_ : " + std::to_string(type_) +
123            ", needStartScan_ : " + (needStartScan_ ? "true" : "false") +
124            ", scanIntervalMs_ : " + std::to_string(scanIntervalMs_) +
125            ", scanTimeoutMs_ : " + std::to_string(scanTimeoutMs_) +
126            ", fixNumber : " + std::to_string(fixNumber_);
127        return str;
128    }
129
130private:
131    int type_;
132    bool needStartScan_;
133    int scanIntervalMs_;
134    int scanTimeoutMs_;
135    int fixNumber_;
136};
137} // namespace Location
138} // namespace OHOS
139#endif // LOCATION_LOCATING_REQUIRED_DATA_CONFIG_H