lomiri-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_LOMIRI_LOCATION_SERVICE_INTERFACE_H_
19 #define LOCATION_SERVICE_COM_LOMIRI_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 #include <core/dbus/types/stl/vector.h>
30 
31 #include <chrono>
32 #include <functional>
33 
34 namespace dbus = core::dbus;
35 
36 namespace com
37 {
38 namespace lomiri
39 {
40 namespace location
41 {
42 struct Criteria;
43 namespace service
44 {
48 class Interface
49 {
50  protected:
51  struct Errors
52  {
54  {
55  inline static std::string name()
56  {
57  return "com.lomiri.location.Service.Error.InsufficientPermissions";
58  }
59  };
61  {
62  inline static std::string name()
63  {
64  return "com.lomiri.location.Service.Error.CreatingSession";
65  }
66  };
67  };
68 
70  {
72 
73  inline static const std::string& name()
74  {
75  static const std::string s
76  {
77  "CreateSessionForCriteria"
78  };
79  return s;
80  }
81 
82  typedef dbus::types::ObjectPath ResultType;
83 
84  inline static const std::chrono::milliseconds default_timeout()
85  {
86  return std::chrono::seconds{25};
87  }
88  };
89 
90  struct Properties
91  {
92  struct State
93  {
94  inline static const std::string& name()
95  {
96  static const std::string s
97  {
98  "State"
99  };
100  return s;
101  }
102 
105  static const bool readable = true;
106  static const bool writable = true;
107  };
108 
110  {
111  inline static const std::string& name()
112  {
113  static const std::string s
114  {
115  "DoesSatelliteBasedPositioning"
116  };
117  return s;
118  }
119 
121  typedef bool ValueType;
122  static const bool readable = true;
123  static const bool writable = true;
124  };
125 
127  {
128  inline static const std::string& name()
129  {
130  static const std::string s
131  {
132  "DoesReportCellAndWifiIds"
133  };
134  return s;
135  }
136 
138  typedef bool ValueType;
139  static const bool readable = true;
140  static const bool writable = true;
141  };
142 
143  struct IsOnline
144  {
145  inline static const std::string& name()
146  {
147  static const std::string s
148  {
149  "IsOnline"
150  };
151  return s;
152  }
153 
155  typedef bool ValueType;
156  static const bool readable = true;
157  static const bool writable = true;
158  };
159 
161  {
162  inline static const std::string& name()
163  {
164  static const std::string s
165  {
166  "VisibleSpaceVehicles"
167  };
168  return s;
169  }
170 
172  typedef std::map<com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle> ValueType;
173 
174  static const bool readable = true;
175  static const bool writable = false;
176  };
177 
179  {
180  inline static const std::string& name()
181  {
182  static const std::string s
183  {
184  "ClientApplications"
185  };
186  return s;
187  }
188 
190  typedef std::vector<std::string> ValueType;
191  static const bool readable = true;
192  static const bool writable = false;
193  };
194  };
195 
196  Interface() = default;
197 
198  public:
199  typedef std::shared_ptr<Interface> Ptr;
200 
204  inline static const std::string& path()
205  {
206  static const std::string s{"/com/lomiri/location/Service"};
207  return s;
208  }
209 
210  Interface(const Interface&) = delete;
211  Interface& operator=(const Interface&) = delete;
212  virtual ~Interface() = default;
213 
218  virtual const core::Property<State>& state() const = 0;
219 
224  virtual core::Property<bool>& does_satellite_based_positioning() = 0;
225 
230  virtual core::Property<bool>& is_online() = 0;
231 
241  virtual core::Property<bool>& does_report_cell_and_wifi_ids() = 0;
242 
246  virtual core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles() = 0;
247 
254  virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0;
255 
260  virtual core::Property<std::vector<std::string>>& client_applications() = 0;
261 };
262 }
263 }
264 }
265 }
266 
267 namespace core
268 {
269 namespace dbus
270 {
271 namespace traits
272 {
273 template<>
274 struct Service<com::lomiri::location::service::Interface>
275 {
276  static const std::string& interface_name()
277  {
278  static const std::string s
279  {
280  "com.lomiri.location.Service"
281  };
282  return s;
283  }
284 };
285 }
286 }
287 }
288 
290 
291 #endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_SERVICE_INTERFACE_H_
com::lomiri::location::service::Interface::Ptr
std::shared_ptr< Interface > Ptr
Definition: interface.h:199
com::lomiri::location::service::Interface::Properties::DoesReportCellAndWifiIds::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:137
core::dbus
Definition: codec.h:40
com::lomiri::location::service::Interface::Properties::DoesSatelliteBasedPositioning::name
static const std::string & name()
Definition: interface.h:111
com::lomiri::location::service::Interface::Properties::IsOnline::name
static const std::string & name()
Definition: interface.h:145
com::lomiri::location::service::Interface::Properties::State::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:103
com::lomiri::location::service::Interface::Properties::State::ValueType
com::lomiri::location::service::State ValueType
Definition: interface.h:104
com::lomiri::location::service::Interface::Properties::ClientApplications::writable
static const bool writable
Definition: interface.h:192
com::lomiri::location::service::Interface::Errors::CreatingSession
Definition: interface.h:60
com::lomiri::location::service::Interface::Properties::VisibleSpaceVehicles
Definition: interface.h:160
com::lomiri::location::service::Interface::does_satellite_based_positioning
virtual core::Property< bool > & does_satellite_based_positioning()=0
Whether the service uses satellite-based positioning.
com::lomiri::location::service::Interface::Properties::DoesReportCellAndWifiIds::ValueType
bool ValueType
Definition: interface.h:138
com::lomiri::location::service::Interface::Properties::VisibleSpaceVehicles::writable
static const bool writable
Definition: interface.h:175
space_vehicle.h
interface.h
com::lomiri::location::service::Interface::CreateSessionForCriteria::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:71
com::lomiri::location::service::Interface
The Interface class models the primary interface to the location service.
Definition: interface.h:48
com::lomiri::location::service::Interface::Properties::DoesReportCellAndWifiIds::readable
static const bool readable
Definition: interface.h:139
codec.h
com::lomiri::location::service::Interface::Properties::IsOnline::ValueType
bool ValueType
Definition: interface.h:155
com::lomiri::location::service::Interface::Errors::InsufficientPermissions::name
static std::string name()
Definition: interface.h:55
com::lomiri::location::service::Interface::Interface
Interface()=default
com::lomiri::location::service::Interface::Properties::DoesSatelliteBasedPositioning::ValueType
bool ValueType
Definition: interface.h:121
com::lomiri::location::service::Interface::Properties::DoesSatelliteBasedPositioning::readable
static const bool readable
Definition: interface.h:122
com::lomiri::location::service::Interface::Properties::ClientApplications::ValueType
std::vector< std::string > ValueType
Definition: interface.h:190
com::lomiri::location::service::Interface::Properties::IsOnline::writable
static const bool writable
Definition: interface.h:157
com::lomiri::location::service::State
State
State enumerates the known states of the service.
Definition: state.h:26
com::lomiri::location::service::Interface::state
virtual const core::Property< State > & state() const =0
The overall state of the service.
com::lomiri::location::service::Interface::Properties::DoesReportCellAndWifiIds::name
static const std::string & name()
Definition: interface.h:128
com::lomiri::location::service::Interface::Properties::DoesSatelliteBasedPositioning::writable
static const bool writable
Definition: interface.h:123
com::lomiri::location::service::Interface::Properties::DoesSatelliteBasedPositioning
Definition: interface.h:109
com::lomiri::location::service::Interface::Properties::IsOnline::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:154
com::lomiri::location::service::Interface::Properties::ClientApplications
Definition: interface.h:178
core
Definition: codec.h:38
com::lomiri::location::service::Interface::CreateSessionForCriteria::ResultType
dbus::types::ObjectPath ResultType
Definition: interface.h:82
com::lomiri::location::service::Interface::Errors::InsufficientPermissions
Definition: interface.h:53
com::lomiri::location::service::Interface::Properties::State::writable
static const bool writable
Definition: interface.h:106
com::lomiri::location::service::Interface::Errors::CreatingSession::name
static std::string name()
Definition: interface.h:62
com::lomiri::location::service::Interface::Properties::DoesReportCellAndWifiIds
Definition: interface.h:126
com::lomiri::location::service::Interface::CreateSessionForCriteria::name
static const std::string & name()
Definition: interface.h:73
core::dbus::traits::Service< com::lomiri::location::service::Interface >::interface_name
static const std::string & interface_name()
Definition: interface.h:276
com::lomiri::location::service::Interface::Errors
Definition: interface.h:51
com::lomiri::location::service::session::Interface::Ptr
std::shared_ptr< Interface > Ptr
Definition: interface.h:105
com::lomiri::location::service::Interface::path
static const std::string & path()
Queries the path that this object is known under.
Definition: interface.h:204
com::lomiri::location::service::Interface::CreateSessionForCriteria
Definition: interface.h:69
com::lomiri::location::service::Interface::Properties::State::readable
static const bool readable
Definition: interface.h:105
com::lomiri::location::service::Interface::is_online
virtual core::Property< bool > & is_online()=0
Whether the overall service and its positioning engine is online or not.
com::lomiri::location::service::Interface::visible_space_vehicles
virtual core::Property< std::map< SpaceVehicle::Key, SpaceVehicle > > & visible_space_vehicles()=0
All space vehicles currently visible.
com::lomiri::location::service::Interface::Properties::VisibleSpaceVehicles::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:171
com::lomiri::location::service::Interface::Properties::DoesSatelliteBasedPositioning::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:120
com::lomiri::location::service::Interface::client_applications
virtual core::Property< std::vector< std::string > > & client_applications()=0
List of application IDs currently requesting position information.
com::lomiri::location::service::Interface::Properties::DoesReportCellAndWifiIds::writable
static const bool writable
Definition: interface.h:140
com::lomiri::location::Criteria
Summarizes criteria of a client session with respect to functionality and accuracy for position,...
Definition: criteria.h:34
com
Definition: accuracy.h:23
com::lomiri::location::service::Interface::Properties::VisibleSpaceVehicles::readable
static const bool readable
Definition: interface.h:174
com::lomiri::location::service::Interface::Properties::IsOnline
Definition: interface.h:143
com::lomiri::location::service::Interface::Properties::VisibleSpaceVehicles::name
static const std::string & name()
Definition: interface.h:162
com::lomiri::location::service::Interface::Properties::State
Definition: interface.h:92
com::lomiri::location::service::Interface::create_session_for_criteria
virtual session::Interface::Ptr create_session_for_criteria(const Criteria &criteria)=0
Starts a new session for the given criteria.
state.h
com::lomiri::location::service::Interface::Properties::ClientApplications::Interface
com::lomiri::location::service::Interface Interface
Definition: interface.h:189
com::lomiri::location::service::Interface::~Interface
virtual ~Interface()=default
com::lomiri::location::service::Interface::CreateSessionForCriteria::default_timeout
static const std::chrono::milliseconds default_timeout()
Definition: interface.h:84
com::lomiri::location::service::Interface::Properties::State::name
static const std::string & name()
Definition: interface.h:94
com::lomiri::location::service::Interface::operator=
Interface & operator=(const Interface &)=delete
com::lomiri::location::service::Interface::does_report_cell_and_wifi_ids
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...
com::lomiri::location::service::Interface::Properties::IsOnline::readable
static const bool readable
Definition: interface.h:156
com::lomiri::location::service::Interface::Properties::ClientApplications::readable
static const bool readable
Definition: interface.h:191
com::lomiri::location::service::Interface::Properties::ClientApplications::name
static const std::string & name()
Definition: interface.h:180
com::lomiri::location::service::Interface::Properties
Definition: interface.h:90
com::lomiri::location::service::Interface::Properties::VisibleSpaceVehicles::ValueType
std::map< com::lomiri::location::SpaceVehicle::Key, com::lomiri::location::SpaceVehicle > ValueType
Definition: interface.h:172