• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_REQUIRED_DATA_H
17 #define LOCATION_REQUIRED_DATA_H
18 
19 #include "bluetooth_scan_info.h"
20 #include "wifi_scan_info.h"
21 
22 namespace OHOS {
23 namespace Location {
24 class LocatingRequiredData : public Parcelable {
25 public:
LocatingRequiredData()26     LocatingRequiredData()
27     {
28         type_ = 0;
29         wifiData_ = std::make_shared<WifiScanInfo>();
30         blueToothData_ = std::make_shared<BluetoothScanInfo>();
31     }
32 
33     ~LocatingRequiredData() override = default;
34 
GetType()35     inline int GetType() const
36     {
37         return type_;
38     }
39 
SetType(int type)40     inline void SetType(int type)
41     {
42         type_ = type;
43     }
44 
GetWifiScanInfo()45     inline std::shared_ptr<WifiScanInfo> GetWifiScanInfo() const
46     {
47         return wifiData_;
48     }
49 
SetWifiScanInfo(std::shared_ptr<WifiScanInfo> wifiData)50     inline void SetWifiScanInfo(std::shared_ptr<WifiScanInfo> wifiData)
51     {
52         wifiData_ = wifiData;
53     }
54 
GetBluetoothScanInfo()55     inline std::shared_ptr<BluetoothScanInfo> GetBluetoothScanInfo() const
56     {
57         return blueToothData_;
58     }
59 
SetBluetoothScanInfo(std::shared_ptr<BluetoothScanInfo> blueToothData)60     inline void SetBluetoothScanInfo(std::shared_ptr<BluetoothScanInfo> blueToothData)
61     {
62         blueToothData_ = blueToothData;
63     }
64 
ReadFromParcel(Parcel & parcel)65     void ReadFromParcel(Parcel& parcel)
66     {
67         type_ =  parcel.ReadInt32();
68         wifiData_ = WifiScanInfo::Unmarshalling(parcel);
69         blueToothData_ = BluetoothScanInfo::Unmarshalling(parcel);
70     }
71 
Marshalling(Parcel & parcel)72     bool Marshalling(Parcel& parcel) const override
73     {
74         return parcel.WriteInt32(type_) &&
75             wifiData_->Marshalling(parcel) &&
76             blueToothData_->Marshalling(parcel);
77     }
78 
Unmarshalling(Parcel & parcel)79     static std::shared_ptr<LocatingRequiredData> Unmarshalling(Parcel& parcel)
80     {
81         auto locatingRequiredData = std::make_shared<LocatingRequiredData>();
82         locatingRequiredData->ReadFromParcel(parcel);
83         return locatingRequiredData;
84     }
85 
ToString()86     std::string ToString()
87     {
88         std::string str = "type_ : " + std::to_string(type_);
89         return str + wifiData_->ToString() + blueToothData_->ToString();
90     }
91 
92 private:
93     int type_;
94     std::shared_ptr<WifiScanInfo> wifiData_;
95     std::shared_ptr<BluetoothScanInfo> blueToothData_;
96 };
97 } // namespace Location
98 } // namespace OHOS
99 #endif // LOCATION_REQUIRED_DATA_H