ubuntu-location-service  ..
An aggregating location service providing positioning and geocoding capabilities to applications.
interface.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as 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: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
20 
22 
24 
25 #include <core/dbus/service.h>
26 #include <core/dbus/traits/service.h>
27 #include <core/dbus/types/object_path.h>
28 
29 #include <chrono>
30 #include <functional>
31 
32 namespace dbus = core::dbus;
33 
34 namespace com
35 {
36 namespace ubuntu
37 {
38 namespace location
39 {
40 struct Criteria;
41 namespace service
42 {
46 class Interface
47 {
48  protected:
49  struct Errors
50  {
52  {
53  inline static std::string name()
54  {
55  return "com.ubuntu.location.Service.Error.InsufficientPermissions";
56  }
57  };
59  {
60  inline static std::string name()
61  {
62  return "com.ubuntu.location.Service.Error.CreatingSession";
63  }
64  };
65  };
66 
68  {
70 
71  inline static const std::string& name()
72  {
73  static const std::string s
74  {
75  "CreateSessionForCriteria"
76  };
77  return s;
78  }
79 
80  typedef dbus::types::ObjectPath ResultType;
81 
82  inline static const std::chrono::milliseconds default_timeout()
83  {
84  return std::chrono::seconds{25};
85  }
86  };
87 
88  struct Properties
89  {
91  {
92  inline static const std::string& name()
93  {
94  static const std::string s
95  {
96  "DoesSatelliteBasedPositioning"
97  };
98  return s;
99  }
100 
102  typedef bool ValueType;
103  static const bool readable = true;
104  static const bool writable = true;
105  };
106 
108  {
109  inline static const std::string& name()
110  {
111  static const std::string s
112  {
113  "DoesReportCellAndWifiIds"
114  };
115  return s;
116  }
117 
119  typedef bool ValueType;
120  static const bool readable = true;
121  static const bool writable = true;
122  };
123 
124  struct IsOnline
125  {
126  inline static const std::string& name()
127  {
128  static const std::string s
129  {
130  "IsOnline"
131  };
132  return s;
133  }
134 
136  typedef bool ValueType;
137  static const bool readable = true;
138  static const bool writable = true;
139  };
140 
142  {
143  inline static const std::string& name()
144  {
145  static const std::string s
146  {
147  "VisibleSpaceVehicles"
148  };
149  return s;
150  }
151 
153  typedef std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle> ValueType;
154 
155  static const bool readable = true;
156  static const bool writable = false;
157  };
158  };
159 
160  Interface() = default;
161 
162  public:
163  typedef std::shared_ptr<Interface> Ptr;
164 
168  inline static const std::string& path()
169  {
170  static const std::string s{"/com/ubuntu/location/Service"};
171  return s;
172  }
173 
174  Interface(const Interface&) = delete;
175  Interface& operator=(const Interface&) = delete;
176  virtual ~Interface() = default;
177 
182  virtual core::Property<bool>& does_satellite_based_positioning() = 0;
183 
188  virtual core::Property<bool>& is_online() = 0;
189 
199  virtual core::Property<bool>& does_report_cell_and_wifi_ids() = 0;
200 
204  virtual core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles() = 0;
205 
212  virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0;
213 };
214 }
215 }
216 }
217 }
218 
219 namespace core
220 {
221 namespace dbus
222 {
223 namespace traits
224 {
225 template<>
226 struct Service<com::ubuntu::location::service::Interface>
227 {
228  static const std::string& interface_name()
229  {
230  static const std::string s
231  {
232  "com.ubuntu.location.Service"
233  };
234  return s;
235  }
236 };
237 }
238 }
239 }
240 
242 
243 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
com::ubuntu::location::service::Interface Interface
Definition: interface.h:69
virtual core::Property< bool > & does_report_cell_and_wifi_ids()=0
Whether the engine and its providers/reporters do call home to report reference locations together wi...
static const std::string & path()
Queries the path that this object is known under.
Definition: interface.h:168
Interface & operator=(const Interface &)=delete
Definition: codec.h:35
Definition: accuracy.h:23
virtual core::Property< bool > & is_online()=0
Whether the overall service and its positioning engine is online or not.
static const std::chrono::milliseconds default_timeout()
Definition: interface.h:82
virtual core::Property< bool > & does_satellite_based_positioning()=0
Whether the service uses satellite-based positioning.
The Interface class models the primary interface to the location service.
Definition: interface.h:46
std::shared_ptr< Interface > Ptr
Definition: interface.h:163
com::ubuntu::location::service::Interface Interface
Definition: interface.h:135
std::map< com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle > ValueType
Definition: interface.h:153
virtual session::Interface::Ptr create_session_for_criteria(const Criteria &criteria)=0
Starts a new session for the given criteria.
Summarizes criteria of a client session with respect to functionality and accuracy for position...
Definition: criteria.h:34
virtual core::Property< std::map< SpaceVehicle::Key, SpaceVehicle > > & visible_space_vehicles()=0
All space vehicles currently visible.