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 
23 
25 
26 #include <core/dbus/service.h>
27 #include <core/dbus/traits/service.h>
28 #include <core/dbus/types/object_path.h>
29 
30 #include <chrono>
31 #include <functional>
32 
33 namespace dbus = core::dbus;
34 
35 namespace com
36 {
37 namespace ubuntu
38 {
39 namespace location
40 {
41 struct Criteria;
42 namespace service
43 {
47 class Interface
48 {
49  protected:
50  struct Errors
51  {
53  {
54  inline static std::string name()
55  {
56  return "com.ubuntu.location.Service.Error.InsufficientPermissions";
57  }
58  };
60  {
61  inline static std::string name()
62  {
63  return "com.ubuntu.location.Service.Error.CreatingSession";
64  }
65  };
66  };
67 
69  {
71 
72  inline static const std::string& name()
73  {
74  static const std::string s
75  {
76  "CreateSessionForCriteria"
77  };
78  return s;
79  }
80 
81  typedef dbus::types::ObjectPath ResultType;
82 
83  inline static const std::chrono::milliseconds default_timeout()
84  {
85  return std::chrono::seconds{25};
86  }
87  };
88 
89  struct Properties
90  {
91  struct State
92  {
93  inline static const std::string& name()
94  {
95  static const std::string s
96  {
97  "State"
98  };
99  return s;
100  }
101 
104  static const bool readable = true;
105  static const bool writable = true;
106  };
107 
109  {
110  inline static const std::string& name()
111  {
112  static const std::string s
113  {
114  "DoesSatelliteBasedPositioning"
115  };
116  return s;
117  }
118 
120  typedef bool ValueType;
121  static const bool readable = true;
122  static const bool writable = true;
123  };
124 
126  {
127  inline static const std::string& name()
128  {
129  static const std::string s
130  {
131  "DoesReportCellAndWifiIds"
132  };
133  return s;
134  }
135 
137  typedef bool ValueType;
138  static const bool readable = true;
139  static const bool writable = true;
140  };
141 
142  struct IsOnline
143  {
144  inline static const std::string& name()
145  {
146  static const std::string s
147  {
148  "IsOnline"
149  };
150  return s;
151  }
152 
154  typedef bool ValueType;
155  static const bool readable = true;
156  static const bool writable = true;
157  };
158 
160  {
161  inline static const std::string& name()
162  {
163  static const std::string s
164  {
165  "VisibleSpaceVehicles"
166  };
167  return s;
168  }
169 
171  typedef std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle> ValueType;
172 
173  static const bool readable = true;
174  static const bool writable = false;
175  };
176  };
177 
178  Interface() = default;
179 
180  public:
181  typedef std::shared_ptr<Interface> Ptr;
182 
186  inline static const std::string& path()
187  {
188  static const std::string s{"/com/ubuntu/location/Service"};
189  return s;
190  }
191 
192  Interface(const Interface&) = delete;
193  Interface& operator=(const Interface&) = delete;
194  virtual ~Interface() = default;
195 
200  virtual const core::Property<State>& state() const = 0;
201 
206  virtual core::Property<bool>& does_satellite_based_positioning() = 0;
207 
212  virtual core::Property<bool>& is_online() = 0;
213 
223  virtual core::Property<bool>& does_report_cell_and_wifi_ids() = 0;
224 
228  virtual core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles() = 0;
229 
236  virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0;
237 };
238 }
239 }
240 }
241 }
242 
243 namespace core
244 {
245 namespace dbus
246 {
247 namespace traits
248 {
249 template<>
250 struct Service<com::ubuntu::location::service::Interface>
251 {
252  static const std::string& interface_name()
253  {
254  static const std::string s
255  {
256  "com.ubuntu.location.Service"
257  };
258  return s;
259  }
260 };
261 }
262 }
263 }
264 
266 
267 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
State
State enumerates the known states of the service.
Definition: state.h:26
com::ubuntu::location::service::Interface Interface
Definition: interface.h:70
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:186
com::ubuntu::location::service::Interface Interface
Definition: interface.h:102
Interface & operator=(const Interface &)=delete
Definition: codec.h:38
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:83
com::ubuntu::location::service::State ValueType
Definition: interface.h:103
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:47
std::shared_ptr< Interface > Ptr
Definition: interface.h:181
com::ubuntu::location::service::Interface Interface
Definition: interface.h:153
std::map< com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle > ValueType
Definition: interface.h:171
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.
virtual const core::Property< State > & state() const =0
The overall state of the service.