• 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 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 
SetTimeStamp(int64_t time)100     inline void SetTimeStamp(int64_t time)
101     {
102         timestamp_ = time;
103     }
104 
GetTimeStamp()105     inline int64_t GetTimeStamp()
106     {
107         return timestamp_;
108     }
109 
SetIsNeedPoi(bool isNeedPoi)110     inline void SetIsNeedPoi(bool isNeedPoi)
111     {
112         isNeedPoi_ = isNeedPoi;
113     }
114 
GetIsNeedPoi()115     inline bool GetIsNeedPoi()
116     {
117         return isNeedPoi_;
118     }
119 
SetIsNeedLocation(bool isNeedLocation)120     inline void SetIsNeedLocation(bool isNeedLocation)
121     {
122         isNeedLocation_ = isNeedLocation;
123     }
124 
GetIsNeedLocation()125     inline bool GetIsNeedLocation()
126     {
127         return isNeedLocation_;
128     }
129 
130     void ReadFromParcel(Parcel& parcel);
131     bool Marshalling(Parcel& parcel) const override;
132     std::string ToString() const;
133     static RequestConfig* Unmarshalling(Parcel& parcel);
134     void Set(RequestConfig& requestConfig);
135     bool IsSame(RequestConfig& requestConfig);
136     bool IsRequestForAccuracy();
137 private:
138     int scenario_;
139     int timeInterval_; /* Units are seconds */
140     double distanceInterval_ = 0.0;
141     float maxAccuracy_;
142     int fixNumber_;
143     int priority_;
144     int timeOut_;
145     int64_t timestamp_;
146     bool isNeedPoi_;
147     bool isNeedLocation_;
148 };
149 } // namespace Location
150 } // namespace OHOS
151 #endif // REQUEST_CONFIG_H
152