Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 Lesser GNU 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 #ifndef UNITY_SCOPES_LOCATION_H
20 #define UNITY_SCOPES_LOCATION_H
21 
22 #include <unity/scopes/Variant.h>
23 #include <unity/util/DefinesPtrs.h>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 
31 namespace internal
32 {
33 
34 class LocationImpl;
35 } // namespace internal
36 
40 class Location final
41 {
42 public:
44  UNITY_DEFINES_PTRS(Location);
46 
52  Location(double latitude, double longitude);
53 
57  Location(VariantMap const& variant);
58 
60  ~Location();
62 
66  //{@
67  Location(Location const& other);
68  Location(Location&&);
69 
70  Location& operator=(Location const& other);
71  Location& operator=(Location&&);
73 
79  double altitude() const; // optional
80 
85  bool has_altitude() const;
86 
92  std::string area_code() const; // optional
93 
98  bool has_area_code() const;
99 
105  std::string city() const; // optional
106 
111  bool has_city() const;
112 
118  std::string country_code() const; // optional
119 
124  bool has_country_code() const;
125 
131  std::string country_name() const; // optional
132 
137  bool has_country_name() const;
138 
144  double horizontal_accuracy() const; // optional
145 
150  bool has_horizontal_accuracy() const;
151 
156  double latitude() const;
157 
162  double longitude() const;
163 
168  VariantMap serialize() const;
169 
175  std::string region_code() const; // optional
176 
181  bool has_region_code() const;
182 
188  std::string region_name() const; // optional
189 
194  bool has_region_name() const;
195 
201  double vertical_accuracy() const; // optional
202 
207  bool has_vertical_accuracy() const;
208 
214  std::string zip_postal_code() const; // optional
215 
220  bool has_zip_postal_code() const;
221 
226  void set_altitude(double altitude);
227 
232  void set_area_code(std::string const& area_code);
233 
238  void set_city(std::string const& city);
239 
244  void set_country_code(std::string const& country_code);
245 
250  void set_country_name(std::string const& country_name);
251 
256  void set_horizontal_accuracy(double horizontal_accuracy);
257 
262  void set_latitude(double latitude);
263 
268  void set_longitude(double longitude);
269 
274  void set_region_code(std::string const& region_code);
275 
280  void set_region_name(std::string const& region_name);
281 
286  void set_vertical_accuracy(double vertical_accuracy);
287 
292  void set_zip_postal_code(std::string const& zip_postal_code);
293 
294 private:
295  std::unique_ptr<internal::LocationImpl> p;
296 
297  friend class internal::LocationImpl;
298 };
299 
300 } // namespace scopes
301 
302 } // namespace unity
303 
304 #endif
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:50
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:39
std::string city() const
Get the city name.
Definition: ActionMetadata.h:32
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:40
void set_longitude(double longitude)
Set the longitude.