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 REQUEST_CONFIG_H 17 #define REQUEST_CONFIG_H 18 19 #include <parcel.h> 20 #include <string> 21 22 namespace OHOS { 23 namespace Location { 24 class RequestConfig : public Parcelable { 25 public: 26 RequestConfig(); 27 explicit RequestConfig(const int scenario); 28 ~RequestConfig() override = default; 29 GetScenario()30 inline int GetScenario() const 31 { 32 return scenario_; 33 } 34 SetScenario(int scenario)35 inline void SetScenario(int scenario) 36 { 37 scenario_ = scenario; 38 } 39 SetPriority(int priority)40 inline void SetPriority(int priority) 41 { 42 priority_ = priority; 43 } 44 GetPriority()45 inline int GetPriority() 46 { 47 return priority_; 48 } 49 GetTimeInterval()50 inline int GetTimeInterval() const 51 { 52 return timeInterval_; 53 } 54 SetTimeInterval(int timeInterval)55 inline void SetTimeInterval(int timeInterval) 56 { 57 timeInterval_ = timeInterval; 58 } 59 GetDistanceInterval()60 inline double GetDistanceInterval() const 61 { 62 return distanceInterval_; 63 } 64 SetDistanceInterval(double distanceInterval)65 inline void SetDistanceInterval(double distanceInterval) 66 { 67 distanceInterval_ = distanceInterval; 68 } 69 GetMaxAccuracy()70 inline float GetMaxAccuracy() const 71 { 72 return maxAccuracy_; 73 } 74 SetMaxAccuracy(float maxAccuracy)75 inline void SetMaxAccuracy(float maxAccuracy) 76 { 77 maxAccuracy_ = maxAccuracy; 78 } 79 SetFixNumber(int fixNumber)80 inline void SetFixNumber(int fixNumber) 81 { 82 fixNumber_ = fixNumber; 83 } 84 GetFixNumber()85 inline int GetFixNumber() 86 { 87 return fixNumber_; 88 } 89 SetTimeOut(int time)90 inline void SetTimeOut(int time) 91 { 92 timeOut_ = time; 93 } 94 GetTimeOut()95 inline int GetTimeOut() 96 { 97 return timeOut_; 98 } 99 100 void ReadFromParcel(Parcel& parcel); 101 bool Marshalling(Parcel& parcel) const override; 102 std::string ToString() const; 103 static std::unique_ptr<RequestConfig> Unmarshalling(Parcel& parcel); 104 void Set(RequestConfig& requestConfig); 105 bool IsSame(RequestConfig& requestConfig); 106 private: 107 int scenario_; 108 int timeInterval_; /* Units are seconds */ 109 double distanceInterval_; 110 float maxAccuracy_; 111 int fixNumber_; 112 int priority_; 113 int timeOut_; 114 }; 115 } // namespace Location 116 } // namespace OHOS 117 #endif // REQUEST_CONFIG_H 118