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_H 17 #define LOCATION_H 18 19 #include <parcel.h> 20 #include <string> 21 22 namespace OHOS { 23 namespace Location { 24 class Location : public Parcelable { 25 public: 26 Location(); 27 explicit Location(Location &location); 28 ~Location() override = default; 29 GetLatitude()30 inline double GetLatitude() const 31 { 32 return latitude_; 33 } 34 SetLatitude(double latitude)35 inline void SetLatitude(double latitude) 36 { 37 latitude_ = latitude; 38 } 39 GetLongitude()40 inline double GetLongitude() const 41 { 42 return longitude_; 43 } 44 SetLongitude(double longitude)45 inline void SetLongitude(double longitude) 46 { 47 longitude_ = longitude; 48 } 49 GetAltitude()50 inline double GetAltitude() const 51 { 52 return altitude_; 53 } 54 SetAltitude(double altitude)55 inline void SetAltitude(double altitude) 56 { 57 altitude_ = altitude; 58 } 59 GetAccuracy()60 inline double GetAccuracy() const 61 { 62 return accuracy_; 63 } 64 SetAccuracy(double accuracy)65 inline void SetAccuracy(double accuracy) 66 { 67 accuracy_ = accuracy; 68 } 69 GetSpeed()70 inline double GetSpeed() const 71 { 72 return speed_; 73 } 74 SetSpeed(double speed)75 inline void SetSpeed(double speed) 76 { 77 speed_ = speed; 78 } 79 GetDirection()80 inline double GetDirection() const 81 { 82 return direction_; 83 } 84 SetDirection(double direction)85 inline void SetDirection(double direction) 86 { 87 direction_ = direction; 88 } 89 GetTimeStamp()90 inline int64_t GetTimeStamp() const 91 { 92 return timeStamp_; 93 } 94 SetTimeStamp(int64_t timeStamp)95 inline void SetTimeStamp(int64_t timeStamp) 96 { 97 timeStamp_ = timeStamp; 98 } 99 GetTimeSinceBoot()100 inline int64_t GetTimeSinceBoot() const 101 { 102 return timeSinceBoot_; 103 } 104 SetTimeSinceBoot(int64_t timeStamp)105 inline void SetTimeSinceBoot(int64_t timeStamp) 106 { 107 timeSinceBoot_ = timeStamp; 108 } GetAdditions()109 inline std::string GetAdditions() const 110 { 111 return additions_; 112 } 113 SetAdditions(const std::string & additions)114 inline void SetAdditions(const std::string &additions) 115 { 116 additions_ = additions; 117 } 118 GetAdditionSize()119 inline int64_t GetAdditionSize() const 120 { 121 return additionSize_; 122 } 123 SetAdditionSize(int64_t size)124 inline void SetAdditionSize(int64_t size) 125 { 126 additionSize_ = size; 127 } 128 GetIsFromMock()129 inline bool GetIsFromMock() const 130 { 131 return isFromMock_; 132 } 133 SetIsFromMock(bool fromMock)134 inline void SetIsFromMock(bool fromMock) 135 { 136 isFromMock_ = fromMock; 137 } 138 GetSourceType()139 inline int32_t GetSourceType() const 140 { 141 return sourceType_; 142 } 143 SetSourceType(int32_t sourceType)144 inline void SetSourceType(int32_t sourceType) 145 { 146 sourceType_ = sourceType; 147 } 148 GetFloorNo()149 inline int32_t GetFloorNo() const 150 { 151 return floorNo_; 152 } 153 SetFloorNo(int32_t floorNo)154 inline void SetFloorNo(int32_t floorNo) 155 { 156 floorNo_ = floorNo; 157 } 158 GetFloorAccuracy()159 inline double GetFloorAccuracy() const 160 { 161 return floorAccuracy_; 162 } 163 SetFloorAccuracy(double floorAccuracy)164 inline void SetFloorAccuracy(double floorAccuracy) 165 { 166 floorAccuracy_ = floorAccuracy; 167 } 168 169 void ReadFromParcel(Parcel& parcel); 170 bool Marshalling(Parcel& parcel) const override; 171 std::string ToString() const; 172 static std::unique_ptr<Location> Unmarshalling(Parcel& parcel); 173 static std::shared_ptr<Location> UnmarshallingShared(Parcel& parcel); 174 private: 175 double latitude_; 176 double longitude_; 177 double altitude_; 178 double accuracy_; 179 double speed_; 180 double direction_; 181 int64_t timeStamp_; 182 int64_t timeSinceBoot_; 183 std::string additions_; 184 int64_t additionSize_; 185 bool isFromMock_; 186 int32_t sourceType_; 187 int32_t floorNo_; 188 double floorAccuracy_; 189 }; 190 } // namespace Location 191 } // namespace OHOS 192 #endif // LOCATION_H