Unity Scopes API
Location.h
1 /*
2  * Copyright (C) 2014 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pete Woods <pete.wods@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/Variant.h>
22 #include <unity/util/DefinesPtrs.h>
23 
24 namespace unity
25 {
26 
27 namespace scopes
28 {
29 
30 namespace internal
31 {
32 
33 class LocationImpl;
34 } // namespace internal
35 
39 class Location final
40 {
41 public:
43  UNITY_DEFINES_PTRS(Location);
45 
51  Location(double latitude, double longitude);
52 
56  Location(VariantMap const& variant);
57 
59  ~Location();
61 
65  //{@
66  Location(Location const& other);
67  Location(Location&&);
68 
69  Location& operator=(Location const& other);
70  Location& operator=(Location&&);
72 
78  double altitude() const; // optional
79 
84  bool has_altitude() const;
85 
91  std::string area_code() const; // optional
92 
97  bool has_area_code() const;
98 
104  std::string city() const; // optional
105 
110  bool has_city() const;
111 
117  std::string country_code() const; // optional
118 
123  bool has_country_code() const;
124 
130  std::string country_name() const; // optional
131 
136  bool has_country_name() const;
137 
143  double horizontal_accuracy() const; // optional
144 
149  bool has_horizontal_accuracy() const;
150 
155  double latitude() const;
156 
161  double longitude() const;
162 
167  VariantMap serialize() const;
168 
174  std::string region_code() const; // optional
175 
180  bool has_region_code() const;
181 
187  std::string region_name() const; // optional
188 
193  bool has_region_name() const;
194 
200  double vertical_accuracy() const; // optional
201 
206  bool has_vertical_accuracy() const;
207 
213  std::string zip_postal_code() const; // optional
214 
219  bool has_zip_postal_code() const;
220 
225  void set_altitude(double altitude);
226 
231  void set_area_code(std::string const& area_code);
232 
237  void set_city(std::string const& city);
238 
243  void set_country_code(std::string const& country_code);
244 
249  void set_country_name(std::string const& country_name);
250 
255  void set_horizontal_accuracy(double horizontal_accuracy);
256 
261  void set_latitude(double latitude);
262 
267  void set_longitude(double longitude);
268 
273  void set_region_code(std::string const& region_code);
274 
279  void set_region_name(std::string const& region_name);
280 
285  void set_vertical_accuracy(double vertical_accuracy);
286 
291  void set_zip_postal_code(std::string const& zip_postal_code);
292 
293 private:
294  std::unique_ptr<internal::LocationImpl> p;
295 
296  friend class internal::LocationImpl;
297 };
298 
299 } // namespace scopes
300 
301 } // namespace unity
bool has_region_name() const
Is there a region name property.
std::string region_name() const
Get the region name.
void set_area_code(std::string const &area_code)
Set the area code.
void set_latitude(double latitude)
Set the latitude.
void set_vertical_accuracy(double vertical_accuracy)
Set the vertical_accuracy.
bool has_region_code() const
Is there a region code property.
std::string country_code() const
Get the country code.
void set_country_name(std::string const &country_name)
Set the country name.
double latitude() const
Get the latitude.
bool has_country_name() const
Is there a country name property.
double longitude() const
Get the longitude.
Location(double latitude, double longitude)
Construct a new Location with the specified latitude and longitude.
void set_city(std::string const &city)
Set the city name.
bool has_zip_postal_code() const
Is there a zip / postal code property.
bool has_country_code() const
Is there a country code property.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
void set_zip_postal_code(std::string const &zip_postal_code)
Set the zip/postal code.
void set_country_code(std::string const &country_code)
Set the country code.
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:38
std::string city() const
Get the city name.
Definition: ActionMetadata.h:31
double vertical_accuracy() const
Get the vertical accuracy.
std::string country_name() const
Get the country name.
std::string region_code() const
Get the region code.
bool has_area_code() const
Is there an area code property.
double altitude() const
Get the altitude.
bool has_vertical_accuracy() const
Is there a vertical accuracy property.
bool has_city() const
Is there a city property.
void set_region_code(std::string const &region_code)
Set the region code.
std::string zip_postal_code() const
Get the zip or postal code.
void set_horizontal_accuracy(double horizontal_accuracy)
Set the horizontal accuracy.
bool has_altitude() const
Is there an altitude property.
VariantMap serialize() const
Return a dictionary of all location attributes.
double horizontal_accuracy() const
Get the horizontal accuracy.
bool has_horizontal_accuracy() const
Is there a horizontal accuracy property.
void set_region_name(std::string const &region_name)
Set the region name.
void set_altitude(double altitude)
Set the altitude.
std::string area_code() const
Get the area code.
Holds location attributes such as latitude, longitude, etc.
Definition: Location.h:39
void set_longitude(double longitude)
Set the longitude.